How do i do Matrix reordering (cutting into blocks)?

3 ビュー (過去 30 日間)
ManvsMachine
ManvsMachine 2019 年 5 月 8 日
コメント済み: ManvsMachine 2019 年 5 月 8 日
Say i have a matrix
A=[1 5 9 13 17 21.....
2 6 10 14 18 22......
3 7 11 15 19 23
4 8 12 16 20 24 .......]
And want to bring that into this shape
A_=[1 5 9 13
2 6 10 14
3 7 11 15
4 8 12 16
17 21 25 29
18 22 26 30
.....................]
Essentially cutting the above matrix into 4*4 and then continuing to the right and bring it down in to the new matrix.How do i do this?thank you

採用された回答

James Tursa
James Tursa 2019 年 5 月 8 日
編集済み: James Tursa 2019 年 5 月 8 日
It's not exactly clear what the actual size of your matrix is (maybe you could clarify), but for what you have posted maybe this is what you want:
result = [A(:,1:4);A(:,5:8)];
EDIT:
Based on your comment below, it would be simpler to reshape the cell array first before you use cell2mat. E.g.,
A = [1 1 0 0 ; 1 1 1 0 ; 0 1 2 0; 1 0 0 1];
Q = cell2mat(arrayfun(@(i) A^i, (1:3)', 'Uni', false)); % transpose the 1:3
  2 件のコメント
ManvsMachine
ManvsMachine 2019 年 5 月 8 日
編集済み: ManvsMachine 2019 年 5 月 8 日
Actually what i am trying to do is
A = [1 1 0 0 ; 1 1 1 0 ; 0 1 2 0; 1 0 0 1];
Q = cell2mat(arrayfun(@(i) A^i, 1:3, 'Uni', false));
size(Q)%4*12 matrix
instead of manually doing , i would like to have reshape or similar command shape this matrix. into
[A
A^2]
A^3]
format
ManvsMachine
ManvsMachine 2019 年 5 月 8 日
Thankyou very much,appreciate your time

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by