Prev: reshaping matrix
Next: QRS detection in ECG
From: santhosh on 2 May 2010 08:58 "Wayne King" <wmkingty(a)gmail.com> wrote in message <hrjqr8$rbk$1(a)fred.mathworks.com>... > "santhosh " <santhosh.ayalur(a)gmail.com> wrote in message <hrjm91$5mg$1(a)fred.mathworks.com>... > > Hi am a beginner to Matlab and have a problem with reshaping a matrix. > > > > I have a matrix which is 1024*4, which is actually a compound of two data sets that are 512*4*2. > > > > that is in short if my matrix is > > 1 2 > > 3 4 > > 5 6 > > 7 8 > > 9 10 > > 11 12 > > > > I want to reshape it as > > 1 2 7 8 > > 3 4 9 10 > > 5 6 11 12 > > > > How do i do this. I bet its a simple thing for you... > > Thanks for your help > > Hi, the simple thing is to use reshape: > > A =[1 2 > 3 4 > 5 6 > 7 8 > 9 10 > 11 12]; > B = reshape(A,size(A,1)/2,size(A,2)*2); > > But you will see that the result is not what you have indicated above. The elements in B are taken columnwise from A so that B will be: > 1 7 2 8 > 3 9 4 10 > 5 11 6 12 > > Are you sure the structure you have indicated for the reshaped matrix is the one you want? Do you really want the 2nd and 3rd columns in the order you have indicated? Or do you want them as reshape() returns? > > Wayne Hi Wayne thanks for the email. I did use reshape the function before writing the email. for the matrix below: a= > > 1 2 > > 3 4 > > 5 6 > > 7 8 > > 9 10 > > 11 12 > > using reshape b=reshape(a,3,4) , i end up as b = 1 7 2 8 3 9 4 10 5 11 6 12 while inded what i need is 1 2 7 8 3 4 9 10 5 6 11 12. I also did b=reshape(a,3,2,2), but then the outpus is not what i wanted. Basically i have a (m*1024)*4 matrix. I only want to reshape m into say 'p', but maintaining the *4 structure. I havent been able to do that in one command.
|
Pages: 1 Prev: reshaping matrix Next: QRS detection in ECG |