Bazman
Bazman

Reputation: 2150

Plotting from 3D matrix in Matlab

I have a matrix which is 1*1*10000, the slightly odd dimensions are the result of the matrix algebra used to calculate it.

I simply want to be able to plot the 10000 data points contained in it, but matlab seems unable to do it?

Can someone please tell me how I can plot the data?

Seems simple but I really can't figure out how to do it!

Baz

Upvotes: 2

Views: 116

Answers (1)

tim
tim

Reputation: 10186

yes you need to reduce the dimensions to a vector:

A = zeros(1,1,100)
vector = squeeze(A(1,1,:))

as when you'd access the third dimension this would only return a 3D-Matrix again:

z = A(1,1,:)

would NOT work. So use squeeze() ;-) Then plot as usual.

Doc-Link: http://www.mathworks.de/de/help/matlab/ref/squeeze.html And as Ander pointed out in comments, no need to give any dimensions, as it removes singleton-dimensions by itself. So just use vector = squeeze(A). MATLAB recognizes the way to go itself.

Upvotes: 5

Related Questions