Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Reshape

10 views
Skip to first unread message

Jerry

unread,
Nov 15, 2012, 3:35:15 PM11/15/12
to
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

Roger Stafford

unread,
Nov 15, 2012, 7:43:15 PM11/15/12
to
"Jerry " <jerry...@gmail.com> wrote in message <k83jm3$4o1$1...@newscl01ah.mathworks.com>...
- - - - - - - - -
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
0 new messages