"Jehad Zughyer" <zjehad@yahoo.com> wrote in message
news:gj8lq6$h6e$1@fred.mathworks.com...
>I am creating matrices out of the first m x n matrix. however with each
>created matrix, I have to rearrange the columns and shift the first column
>to the right one column. Reshape and circshift did not do what I intend. I
>am demonstrating what I need to do using a 3X4 matrix:
>
> a= 0 0 0
> 0 0 1
> 0 1 0
> 0 1 1
> I always need to create a big ( A ) matrix such as replicating (a ) the
> same number of its columns ( 3 in this example). I start with (a), then
> the next (a) I need to shift the first column (always all zeros) to the
> second column. Then the third (a), moves it to the third column.... Keep
> doing this until n , number of columns is reached. The end matrix for
> this example will look like this:
>
> A= 0 0 0
> 0 0 1
> 0 1 0
> 0 1 1
> 0 0 0
> 0 0 1
> 1 0 0
> 1 0 1
> 0 0 0
> 0 1 0
> 1 0 0
> 1 1 0
>
> Any tips?
>
Just use a for loop?
>> a=[ 0 0 0;
0 0 1;
0 1 0;
0 1 1];
[nRow,nCol]=size(a);
A=zeros(nRow*nCol,nCol);
A(1:nRow,:)=a;
for i=1:nCol1
x=a(:,i);
a(:,i)=a(:,i+1);
a(:,i+1)=x;
A(i*nRow+1:(i+1)*nRow,:)=a;
end
A =
0 0 0
0 0 1
0 1 0
0 1 1
0 0 0
0 0 1
1 0 0
1 0 1
0 0 0
0 1 0
1 0 0
1 1 0
Nasser
