Convert matrix size from 1xmxn to mxn
76 ビュー (過去 30 日間)
古いコメントを表示
I want to compare two matrices. One's size is mxn and the other matrix size 1xmxn. How can I convert 1xmxn to mxn??
0 件のコメント
採用された回答
Andrei Bobrov
2014 年 7 月 2 日
編集済み: Andrei Bobrov
2014 年 7 月 2 日
Z = randi(250,1,3,4); % your matrix
one way
out = squeeze(Z)';
other
out = permute(Z,[3 2 1]);
or
out = reshape(Z,size(Z,2),[])';
1 件のコメント
Erik Kruit
2020 年 10 月 13 日
編集済み: Erik Kruit
2020 年 10 月 13 日
Googled really long on this! Thanks!
size(A)=1xMxN matrix. Unable to then imagsc(A(jpos,:,:))
error(using image Color data must be an m-by-n-by-3 or m-by-n matrix.)
Solved by:
Qi=squeeze(A(jpos,:,:));
imagesc(Qi);
% Squeeze used to convert the resulting 1xMxN matrix into a MxN matrix
その他の回答 (1 件)
Piyush kant
2019 年 4 月 9 日
Just adding some context to previous answer by Andrei Bobrov. Basic idea is to convert 1 x m x n matrix into m x n x 1 as matlab omits last dimension if it is 1. Therefore the method i prefer is:
NewMat=sqeeze(Z)';
Whereas other two functions does the same thing.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Logical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!