hello,
i am new to matlab.. i am finiding difficulty in combining arreys in
rows n columns
i have a matrix A of size 2*2, i can access it on 3rd dimension
e.g A(:,:,1)=(34 35 ; 36 37)
A(:,:,2)=(4 5 ; 6 7)
..
..
..
i want to combine in such a way that if A has 9 such 2*2 small matrics
then the output should be a matrix B where
B=[ A(:,:,1) A(:,:,4) A(:,:,7)
A(:,:,2) A(:,:,5) A(:,:,8)
A(:,:,3) A(:,:,6) A(:,:,9)]
if anyone has solution ....please post it
thanks in advance
|
|
0
|
|
|
|
Reply
|
neha
|
2/18/2011 2:35:59 PM |
|
"Neha Dharme" wrote in message <92f1c606-61b6-4626-8065-e47aff3cad4f@y30g2000prf.googlegroups.com>...
> hello,
>
> i am new to matlab.. i am finiding difficulty in combining arreys in
> rows n columns
>
> i have a matrix A of size 2*2, i can access it on 3rd dimension
>
> e.g A(:,:,1)=(34 35 ; 36 37)
> A(:,:,2)=(4 5 ; 6 7)
> .
> .
> .
>
> i want to combine in such a way that if A has 9 such 2*2 small matrics
> then the output should be a matrix B where
>
> B=[ A(:,:,1) A(:,:,4) A(:,:,7)
> A(:,:,2) A(:,:,5) A(:,:,8)
> A(:,:,3) A(:,:,6) A(:,:,9)]
>
> if anyone has solution ....please post it
> thanks in advance
If I understood correctly, A is not "of size 2*2" but actually a 2-by-2-by-9 array. To rearrange the planes into the format you can apply some trickery like this
A = zeros(2,2,9) ; for k = 1:9, A(:,:,k) = k ; end % test matrix A
B = cell2mat(reshape(mat2cell(A,2,2,ones(1,9)),3,3))
~ Jos
|
|
0
|
|
|
|
Reply
|
Jos
|
2/18/2011 3:35:04 PM
|
|
|
1 Replies
518 Views
(page loaded in 0.176 seconds)
|