Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Copy a set of coloumn from one matrix to another.
Date: Fri, 11 Nov 2011 03:36:28 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 19
Message-ID: <j9i57s$9q2$1@newscl01ah.mathworks.com>
References: <j9h55n$qht$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-02-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1320982588 10050 172.30.248.47 (11 Nov 2011 03:36:28 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 11 Nov 2011 03:36:28 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:749063

"Bal kishore Pandey" <balkishore.pandey@gmail.com> wrote in message <j9h55n$qht$1@newscl01ah.mathworks.com>...
> ..........
> For eg, A= [1 2 3 4 5 6 7 8 9
>                  9 8 7 6 5 4 3 2 1
>                  3 4 5 6 4 5 6 8 9 
>                  6 7 8 9 3 4 5 6 7
>                  3 4 6 7 8 9 0 1 2 ]  
> 
> I have this matrix and my coloumn_window_size is 2 and my row_window_size is 3 then the code should copy 1 2(coloumn 1 in A) to B matrix exactly in the same position it was in A. Then it should copy 7 6(coloumn 2) , and then 4 5(coloumn 3) and it should start again from the 4th coloumn copying 6 7 , 6 7
- - - - - - - - -
  As nearly as I could decipher your request, the following might do the job.  Let r be the "row_window_size" and c the "column_window_size".  Then do this:

 p = size(A,1);
 ix = ceil((1:p*c)/c)+p*mod(0:p*c-1,r*c);
 B(ix) = A(ix);

  It seems to me you are confusing rows with columns in some of your description, so I am far from certain that this is what you really want.  Moreover it isn't clear that the copy process should end when reaching the bottom row of A.  Perhaps you meant for it to recommence back up at the first row again and r*c elements over to the right?  The above code does not do that.

Roger Stafford