フィルターのクリア

Reshape a matrix dimension

3 ビュー (過去 30 日間)
DM
DM 2017 年 2 月 3 日
コメント済み: Jonah Pearl 2020 年 9 月 2 日
I have a matrix A which has dimension 1320 x14x4 and I would like to make it a matrix of dimension 12x110x14x4. I know I should use the
reshape
but now sure sure how to use it.

回答 (2 件)

the cyclist
the cyclist 2017 年 2 月 3 日
編集済み: the cyclist 2017 年 2 月 3 日
reshape(A,[12,110,14,4])
You should be careful that the elements are being reordered in the order you intend. MATLAB is going to read down the 1st column, then the 2nd column, etc, and then go to the next "plane" along the 3rd dimension.
Depending on what order you actually want, you may need to sneak a transpose in there.
  2 件のコメント
Stephen23
Stephen23 2017 年 2 月 3 日
Transpose is not defined for ND arrays. It would have to be permute.
the cyclist
the cyclist 2017 年 2 月 3 日
Yes, sorry, I just meant transpose in the math sense! Agreed that the permute function might be needed.

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


Stephen23
Stephen23 2017 年 2 月 3 日
編集済み: Stephen23 2017 年 2 月 3 日
reshape(A,12,110,14,4)
and you might need permute too.
MATLAB has excellent documentation online, which is free for anyone to read. I just used [famous search engine] and this was the very first result:
The documentation even explains what it does, what the required inputs and outputs are, and gives complete working examples! We don't have to guess how MATLAB works, because the documentation tell us.
  1 件のコメント
Jonah Pearl
Jonah Pearl 2020 年 9 月 2 日
The MATLAB documentation is prettt sparse for reshape...the closest thing to an explanation about OP's question (which I also have) is " The elements in B also maintain their columnwise order from A." There's nothing helpful on multi-dimensional reshaping. But I agree that we can just mess around.

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

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by