qickyly change 3D matrix to 2D matrix

1 回表示 (過去 30 日間)
Shan  Chu
Shan Chu 2017 年 2 月 16 日
回答済み: Rahul Kalampattel 2017 年 2 月 16 日
Hi, This might be such a silly question but could anyone please help? I get a 3D matrix A(n,m,k) so I want to take the value a(:,1)=A(1,1,:). But Matlab doesn't allow me to do that. Is using "for" loop the only way to do that?

採用された回答

Roger Stafford
Roger Stafford 2017 年 2 月 16 日
編集済み: Roger Stafford 2017 年 2 月 16 日
You could accomplish that with:
a = reshape(permute(A,[3,1,2]),size(A,3),[]);
[Note: You really haven’t specified how the first two dimensions in A should be arranged in the single second dimension of a. Here I have taken the default arrangement.]

その他の回答 (1 件)

Rahul Kalampattel
Rahul Kalampattel 2017 年 2 月 16 日
For the example you gave, the following also works:
a=squeeze(A(1,1,:));

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by