P/S: A(:,:,1) = [1;0;1]
A(:,:,2) = [1;1;1]
SQUEEZE(A) ;
gives A = [1 1
0 1
1 1]
Thanks in advance.
====================================================
Dennis Wong
Signal Processing & Communication Division
Department of Electrical Engineering & Electronics
University of Liverpool
Brownlow Hill
Liverpool L69 3BX
Email: M.L.D...@liv.ac.uk Tel: 0151-7944541
====================================================
A year spent in Artificial Intelligence is enough
for one to believe in God.
The "inverse" of SQUEEZE is RESHAPE. You need to specify the array
you want to "unsqeeze" and the size the array had before it was
squeezed:
A(:,:,1) = [1;0;1];
A(:,:,2) = [1;1;1];
S = size(A); % size before squeezing
B = squeeze(A); % squeeze
C = reshape(B, S); % "unsqueeze"
» isequal(A, C)
ans =
1
Peter
--
function Y = rot90(X, N); s=size(X); d=ndims(X); i={':'}; i=i(ones(d, 1), 1);
%ROT90 Rotate an array X, N*90 degrees counterclockwise along all dimensions.
N = N-4*floor(N/4); if (N==1)|(N==2), i{2} = s(2):-1:1; end; if (N==2)|(N==3)
i{1}=s(1):-1:1; end; Y=X(i{:}); if (N==1)|(N==3), Y=permute(Y,[2 1 3:d]); end
» reshape(s,6,1)
ans =
1
0
1
1
1
1
Dennis Wong wrote:
> I squeezed a 3 dimension single column(:,1,3) Matrix, to a single
> dimension 3 column (:,3,1) matrix, Question is how can I now after
> processing, change it back to 3 dimension single column Matrix?
>
> P/S: A(:,:,1) = [1;0;1]
> A(:,:,2) = [1;1;1]
> SQUEEZE(A) ;
> gives A = [1 1
> 0 1
> 1 1]
>
(A little pedantic here perhaps.) I believe that in Matlab lingo,
a matrix can not have more than 2 dimensions. Arrays, however, can
have an arbitrary number of dimensions. Thus, A in the example above,
is an array, but not a matrix.
Sri Kumar Kanajan <sk...@doc.ic.ac.uk> writes:
>
> s=squeeze(A)
>
> » reshape(s,6,1)
>
> ans =
>
> 1
> 0
> 1
> 1
> 1
> 1
This is a single column array, but it doesn't have 3 dimensions (as
asked for by the original poster)...
Peter
--
disp(reshape(cat(5,cat(4,cat(3,cat(2,'Ju','st'),cat(2,' a','no')),cat...
(3,cat(2,'th','er'),cat(2,' M','at')),cat(4,cat(3,cat(2,'la','b '),...
cat(2,'ha','ck')),cat(3,cat(2,'er',' '),cat(2,' ',' '))))),1,32))