Make 3 dimensional matrix
3 ビュー (過去 30 日間)
古いコメントを表示
Hi, I attached mathworks data including 3 variables Lat,Lon,val.
I want to make 3 dimensional matrix like below. (LatXLonXval)=(9X11X10) maybe
Can you help me? I can't understand well about making matrix
0 件のコメント
採用された回答
Taru
2022 年 11 月 22 日
Hi,
I understand that you want to create a 3D matrix with the provided 2D matrix.
MATLAB provides a function reshape which manipulates the given matrix to the suited dimensions but arranges the elements in column wise manner. The arrangement you want is achieved through row wise arrangement.
Use the following code to get the required matrix:
ans=zeros(9,11,10);
for i=1:10
ans(:,:,i)=val([1:9]+9*(i-1),:);
end
I hope this helps.
0 件のコメント
その他の回答 (1 件)
KSSV
2022 年 11 月 22 日
[r,c] = size(val);
nlay = 10 ;
iwant = permute(reshape(val',[c,r/nlay,nlay]),[2,1,3]);
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Creating and Concatenating Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!