フィルターのクリア

How to concatenate this matrix?

1 回表示 (過去 30 日間)
Ismat
Ismat 2022 年 12 月 9 日
編集済み: Stephen23 2022 年 12 月 9 日
I want to concatenate this "A" matrix vertically. How to do that?I can do that manually. But I want to do it with a loop or in a vectorized way.
A=[1 4 7 10 13 16 19 22 25;
2 5 8 11 14 17 20 23 26;
3 6 9 12 15 18 21 24 27]
output=[A(:,1:3);A(:,4:6);A(:,7:9)] % But I want to do it with a loop or in a vectorized way.
My expected output:
output:[1 4 7;
2 5 8;
3 6 9;
10 13 16;
11 14 17;
12 15 18;
19 22 25;
20 23 26;
21 24 27]

採用された回答

Stephen23
Stephen23 2022 年 12 月 9 日
編集済み: Stephen23 2022 年 12 月 9 日
A = [1,4,7,10,13,16,19,22,25;2,5,8,11,14,17,20,23,26;3,6,9,12,15,18,21,24,27]
A = 3×9
1 4 7 10 13 16 19 22 25 2 5 8 11 14 17 20 23 26 3 6 9 12 15 18 21 24 27
B = reshape(permute(reshape(A,3,3,[]),[1,3,2]),[],3)
B = 9×3
1 4 7 2 5 8 3 6 9 10 13 16 11 14 17 12 15 18 19 22 25 20 23 26 21 24 27

その他の回答 (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