|
"Jerry " <jerrycholo@gmail.com> wrote in message <k83jm3$4o1$1@newscl01ah.mathworks.com>...
> Hello,
>
> A=rand (201,7152);
>
> "A" is a matrix and I would like to reshape "A" to "B"
>
> B=reshape (A,59898,24);
>
> "B" is not going to be what I expected since it is getting mixed up. For example
>
> C=A(:,1:24);
> D=B(1:201,:);
>
> isequal(C, D)
>
> ans =
>
> 0
> How can I reshape "A" to get "C" equal with "D".
>
> Thanks,
> Jerry
- - - - - - - - -
To get the kind of rearrangement you have in mind takes more than a simple 'reshape'. One has to do a little permuting first. Do this:
r = 298; % The number of your blocks
[p,t] = size(A); % p = 201, t = 7152
q = t/r; % t must be divisible by r, q = 24
s = 0:p*q*r-1;
B = reshape(A(1+s+p*((q-1)*floor(s/p)-(q*r-1)*floor(s/(p*r)))),p*r,q);
Roger Stafford
|