フィルターのクリア

Converge a 1x30 row vector to a 3x10 matrix

4 ビュー (過去 30 日間)
Wietze Zijpp
Wietze Zijpp 2022 年 4 月 5 日
コメント済み: Voss 2022 年 4 月 6 日
Suppose I have the following
z = [1:30]
Now I want to create a 3x 10 matrix. Where the entries in the first row are the first 10 values. In the second row entries 11:20 and in the third row 21:30

採用された回答

Wietze Zijpp
Wietze Zijpp 2022 年 4 月 5 日
編集済み: Torsten 2022 年 4 月 5 日
I have found the solution
Use
mymat = reshape(z,3,10)
  1 件のコメント
Voss
Voss 2022 年 4 月 6 日
"the entries in the first row are the first 10 values. In the second row entries 11:20 and in the third row 21:30"
If you want the order like that, you have to do it differently:
z = 1:30;
mymat = reshape(z,3,10)
mymat = 3×10
1 4 7 10 13 16 19 22 25 28 2 5 8 11 14 17 20 23 26 29 3 6 9 12 15 18 21 24 27 30
mymat = reshape(z,10,3).'
mymat = 3×10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by