Plotting a multi-dimensional matrix

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

What type of plot are you wanting to create?
a simple plot but i have a multi dimesional matrix
data= squeeze(A((353:411),(424:499),:))
this is the command for data and the 3 dimension is having the value of 1230. any type of plot that can i plot
Look at plot3, maybe???
You still haven't answered @Cris LaPierre's Q? about what kind of a plot are you trying to create? What are the data variables -- independent/dependent, description of what are...??? We could possibly suggest something appropriate if we only knew the problem space...
A plot of rows and columns of all the dimensions of matrix. i have a matrix with 480x720x1230 dimensions and i want to plot a all the values from row 353 to 411 and column 424 to 499 of all the values in 1230 pages. 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
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.
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)

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.
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)

Products

Release

R2021b

Asked:

on 6 Aug 2022

Answered:

on 6 Aug 2022

Community Treasure Hunt

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

Start Hunting!