Remove xticks but keep xticklabels in MATLAB
Try modifying the TickLength property: set(gca, ‘Ticklength’, [0 0])
Try modifying the TickLength property: set(gca, ‘Ticklength’, [0 0])
There’s no way I know of within the expression of the anonymous function to have it select which output to return from a function with multiple possible output arguments. However, you can return multiple outputs when you evaluate the anonymous function. Here’s an example using the function MAX: >> data = [1 3 2 5 … Read more
How about date = datestr(unix_time/86400 + datenum(1970,1,1)) if unix_time is given in seconds, unix_time/86400 will give the number of days since Jan. 1st 1970. Add to that the offset used by Matlab’s datenum (datenum(0000,1,1) == 1), and you have the amount of days since Jan. 1st, 0000. This can be easily converted to human-readable form … Read more
To fit a curve onto a set of points, we can use ordinary least-squares regression. There is a solution page by MathWorks describing the process. As an example, let’s start with some random data: % some 3d points data = mvnrnd([0 0 0], [1 -0.5 0.8; -0.5 1.1 0; 0.8 0 1], 50); As @BasSwinckels … Read more
Well, there are a few ways how multiple data series can be displayed in the same figure. I will use a little example data set, together with corresponding colors: %% Data t = 0:100; f1 = 0.3; f2 = 0.07; u1 = sin(f1*t); cu1 = ‘r’; %red u2 = cos(f2*t); cu2 = ‘b’; %blue v1 … Read more
Matlab has a function called printmat in the Control Systems toolbox. It’s in the directory “ctrlobsolete“, so we can assume that it is considered “obsolete”, but it still works. The help text is: >> help printmat printmat Print matrix with labels. printmat(A,NAME,RLAB,CLAB) prints the matrix A with the row labels RLAB and column labels CLAB. … Read more
This is not strictly an answer but rather my contribution to the discussion I used the profiler to investigate a slightly-modified version of your code: N_arr = 200:400:3800; %// for medium to large sized input array for k1 = 1:numel(N_arr) A = randi(1,N_arr(k1)); [~]=eq(A,0); clear A A = randi(1,N_arr(k1)); [~]=not(A); clear A end I used … Read more
Look at the filter function. If you just need a 1-pole low-pass filter, it’s xfilt = filter(a, [1 a-1], x); where a = T/τ, T = the time between samples, and τ (tau) is the filter time constant. Here’s the corresponding high-pass filter: xfilt = filter([1-a a-1],[1 a-1], x); If you need to design a … Read more
MATLAB has access to Java: >> a=java.util.LinkedList; >> li=a.listIterator; >> li.add(2); >> li.add(int8(77)); >> li.add(77); >> li.add(boolean(true)); >> li.add(‘Mr. Bill’); >> li.previous(); >> li.add([1 2 3 4 5]); >> a a = [2.0, 77, 77.0, true, [D@66a917, Mr. Bill] >> a.get(4) ans = 1 2 3 4 5 The one downside of this approach is … Read more
This worked for me: figure(‘units’,’normalized’,’outerposition’,[0 0 1 1]) or for current figure: set(gcf,’units’,’normalized’,’outerposition’,[0 0 1 1]) I have also used MAXIMIZE function on FileExchange that uses java. This is true maximization.