필터 지우기
필터 지우기

Make 3 dimensional matrix

조회 수: 1 (최근 30일)
주희 박
주희 박 2022년 11월 22일
답변: Taru 2022년 11월 22일
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

채택된 답변

Taru
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.

추가 답변 (1개)

KSSV
KSSV 2022년 11월 22일
[r,c] = size(val);
nlay = 10 ;
iwant = permute(reshape(val',[c,r/nlay,nlay]),[2,1,3]);

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by