Plotting a multi-dimensional matrix
7 views (last 30 days)
Cris LaPierre on 6 Aug 2022
Edited: Cris LaPierre on 6 Aug 2022
If you want to create a 2D line plot where there is a different line (data series) for each sheet of your array, the simplest way I can think of is to reshape the data so that all the data for a given sheet is in a column. This would be your x values per your earlier description. For y, you would create a vector from 1:1230. Then you would just do plot(x,y).
From the plot documentation page: If all the sets share the same x- or y-coordinates, specify the shared coordinates as a vector and the other coordinates as a matrix. The length of the vector must match one of the dimensions of the matrix.
Here's an example using randomly generated data.
A = rand(480,720,1230);
% extract data
% create x by reshaping data into 4484x1230 array
x = reshape(data,,size(data,3));
% Create y to correspond to sheet number
y = 1:size(data,3);
Steven Lord on 6 Aug 2022
In MATLAB select the Plots tab on the Toolstrip. Click the small downward pointing triangle to the right side of the Plots section of that tab. Look at the small thumbnail pictures and take a look at the documentation for the function name below the one that looks close to the picture you want to create. That should include an example that you can use as a starting point for creating your own plot.
If none of them look like what you want to create, post a link to a picture showing us what you want to see. Just saying "I want a plot" is like saying "I want to eat" -- we can't make you food without knowing whether you want cereal, toast, a sandwich, a steak, curry, etc.