Reputation: 15
I have a 3D matrix u(151,1001,2001) and I need a particular row extracted from it (let's say (51,1,:) in a form of a vector so I could plot it as a time series.
Is there any way that could be done?
Upvotes: 0
Views: 322
Reputation: 7751
There is a Matlab function for that called squeeze
(web) that
returns an array B with the same elements as A, but with all singleton dimensions removed.
when computing
B = squeeze(A)
In your case,
v = squeeze(u(51,1,:));
Upvotes: 0
Reputation: 36710
To convert anything to a column vector, you can use (:)
in matlab:
v=u(51,1,:);
v=v(:);
Alternatives to solve this problem are reshape
and permute
, two functions you will probably need when you proceed with 3D-Matrices.
Upvotes: 1