In order to use plot() efficiently, you should prepare the data to call it just one time. plot() treats each column of 2D arrays as a separate line. So if you had, for example, a 3x4x5 matrix, you need 12 lines of 5 points. You should first permute the matrix and then reshape it to have all of the data in columns. If M is your dataset, then:
M = rand (3, 4, 5);
Dim = size (M);
M2 = permute (M, [3,2,1]);
M3 = reshape (M2(:), Dim(3), []);
plot (M3);
Best Answer