Plotting a multi-dimensional matrix

77 views (last 30 days)
Maheen Khan
Maheen Khan on 6 Aug 2022
Answered: Steven Lord on 6 Aug 2022
I want to plot a matrix from (353:411) rows and (424:499) columns across all the pages of the matrix. Is there any way to do that other than using plot as it is giving us error that "cannot plot three elements".
  7 Comments
dpb
dpb on 6 Aug 2022
Edited: dpb on 6 Aug 2022
"I want to plot the values present on these row, column with those values on x-axis and no. of pages (1230) on y-axis"
Sorry, I can't follow the above...the "those" above reference is imprecise as to what values it means on which axis.
If you mean X(335,424,:) is a line for the 1230 planes and you want one of those for each combination of the above rows, that's 58*75 = 4,3350 combinations so that _probably_ is not what you intend...
How about making up a very small subset 3D array to mimic the storage arrangement you have and show us specifically which pieces of it would match what you're asking for on a much smaller scale? It could be as small as 5x7x3 or something; the number of elements is immaterial to the logic; we just need to be able to understand what you're trying to describe.
Maheen Khan
Maheen Khan on 6 Aug 2022
i want to get a matrix out of my multi dimensional matrix of 480x720x1230 that contain the values from row 353 to 411 and columns 424 to 499 across all the 1230 frames and plot it with the values of matrix on y-axis and number of frames on x-axis

Sign in to comment.

Answers (2)

Steven Lord
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.

Cris LaPierre
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
data= A((353:411),(424:499),:);
% 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);
plot(x,y)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!