How to change M*1*N matrix to M*N matrix

30 views (last 30 days)
I have a signal M*K*N matrix , and I want to display an slice of signal in xz plane something like: imagesc(a( : , 1, : )) but a( : , 1, : ) is considered as 3 dimensional matrix and can not be shown and always this message appears :
imagesc(abs(a(:,1,:)))
??? Error using ==> image
Error using ==> image
Indexed CData must be size [MxN], TrueColor CData must be size [MxNx3]
Error in ==> imagesc at 19 hh = image(varargin{1},'CDataMapping','scaled');
how can change this 3d matrix to a 2d with M*N?

Accepted Answer

the cyclist
the cyclist on 17 Nov 2011
permute(a,[1 3 2])
  4 Comments
Jesny Antony
Jesny Antony on 22 Nov 2016
I too have used this...and it works fine.. thank u so much..
aziza saber
aziza saber on 5 Oct 2020
I appreaciate your answer Jan. I tworks perfect:)

Sign in to comment.

More Answers (1)

Wayne King
Wayne King on 17 Nov 2011
Hi, use squeeze()
X = randn(10,1,10);
Y = squeeze(X);
  2 Comments
the cyclist
the cyclist on 17 Nov 2011
In my experience, permute() is a more robust option than squeeze(). In particular, if any other dimension of the input array also happens to be length one, you might unexpectedly squeeze it away.
Titus Edelhofer
Titus Edelhofer on 17 Nov 2011
Right. In cases I know the dimensions I prefer reshape: say a is of size Mx1xN, I use b = reshape(a, M, N);

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!