Looping through a 3D matrix with third dimension data grouping

조회 수: 1 (최근 30일)
Evelyne Aiyana
Evelyne Aiyana 2019년 8월 3일
댓글: Evelyne Aiyana 2019년 8월 5일
hy everyone, i new to matlab. i use matlab 2013a. my problem is not understanding in making programs in the form of looping functions for 3D matrix 144,12,855
I want to run the following code such that it performs the function element by element through the 3rd dimension (but does not use all 855 points). I have grouped the data. I want this to be done for every pixel giving me 1728 outputs (144*12).
%Average the data against latitude to be 3D
angin_o1 = squeeze(mean(angin_o(1:144,31:43,1:12,1:855),2));
% classify strong el nino years
a=squeeze(mean(angin_o1(:,:,37:48),3));
b=squeeze(mean(angin_o1(:,109:120),3));
c=squeeze(mean(angin_o1(:,181:192),3));
d=squeeze(mean(angin_o1(:,205:216),3));
e=squeeze(mean(angin_o1(:,217:228),3));
f=squeeze(mean(angin_o1(:,289:300),3));
g=squeeze(mean(angin_o1(:,409:420),3));
h=squeeze(mean(angin_o1(:,421:432),3));
i=squeeze(mean(angin_o1(:,469:480),3));
j=squeeze(mean(angin_o1(:,529:540),3));
k=squeeze(mean(angin_o1(:,589:600),3));
l=squeeze(mean(angin_o1(:,601:612),3));
m=squeeze(mean(angin_o1(:,805:816),3));
n=squeeze(mean(angin_o1(:,817:828),3));
for r=1:1:length(lon(:));
for s=1:1:length(y);
o=a(:,1:1:12);
for t=1:1:length(o);
% dlmwrite(a,y,u)
end
end
end
and I don't really understand about using the loop function for 3-dimensional matrices. Thank you for the help.
  댓글 수: 3
darova
darova 2019년 8월 3일
If you want to loop through third dimension:
for i = 1:n
angin_o1(1,1,i) % select (1,1,i) element
end
Is that your question?
Evelyne Aiyana
Evelyne Aiyana 2019년 8월 5일
I plot the x and y axes, which are longitude and height (144 * 12) to the average wind value (a to n)

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by