フィルターのクリア

Reshape an Matlab array

2 ビュー (過去 30 日間)
Yro
Yro 2020 年 12 月 9 日
コメント済み: Yro 2020 年 12 月 9 日
I have the following arrangement (84x2):
RELOADING_PATTERN = [...
26 24
26 35
27 34
27 33
26 33
25 34
25 35
...
] ;
How can I reshape the arrangement to (7x24)?. I tried the reshape function as follows but it doesn't work:
A = reshape(RELOADING_PATTERN(1:84,:),7,24);
I want to get the following array:
A = 26 24 28 24 ...
26 35 29 24 ...
27 34 29 33 ...
27 33 28 33 ...
26 33 27 34 ...
25 34 27 35 ...
25 35 29 34 ...
Thanks in advance.
  3 件のコメント
Yro
Yro 2020 年 12 月 9 日
編集済み: Yro 2020 年 12 月 9 日
Thanks for your reply, sorry I already edited the question, i need to get a 7x24 array. Attached the pattern
Yro
Yro 2020 年 12 月 9 日
Using what you recommend doesn't work, I don't get the desired array,
A=reshape(RELOADING_PATTERN,7,[]);

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

採用された回答

James Tursa
James Tursa 2020 年 12 月 9 日
編集済み: James Tursa 2020 年 12 月 9 日
A straightforward assignment:
A = zeros(7,24);
A(:,1:2:end) = reshape(RELOADING_PATTERN(:,1),7,12);
A(:,2:2:end) = reshape(RELOADING_PATTERN(:,2),7,12);
or using permute etc.
A = reshape(permute(reshape(RELOADING_PATTERN',2,7,[]),[2 1 3]),7,24);
  1 件のコメント
Yro
Yro 2020 年 12 月 9 日
Thanks a lot. It works.

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

その他の回答 (0 件)

カテゴリ

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

タグ

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by