Looping through a 3D matrix with third dimension data grouping
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
darova
el 3 de Ag. de 2019
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?
Respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!