For cycle over a struct array

1 次查看(过去 30 天)
Hello everyone,
I am considering a 1x1 struct array ( named hs) that contains 49 matrices ( 72x77) that represent the significant wave height in all the grid points of my domain. I would like to create a for cycle to plot how the significant wave height is changing during time/space. I know how to extract the matrices one by one from the struct array but it is time consuming and I would like to create a cycle ( with the pcolor command).
Xp (72x77) is the matrix that contains the x-coord of the grid points
Yp (72x77) is the matrix that contains the y-coord of the grid points
How can i write the for loop?
Thank you for your help.
  2 个评论
Tiziano Bagnasco
Tiziano Bagnasco 2022-5-30
Thank you for your answer! This is the content of 1x1 struct array..
I can extract a matrix in this way : hs1=hs.Hsig_20000103_000000(:,:);
But I am not able to create a for cycle like this ( of course what I wrote below doesn't work.. it is just to show what I kind of want to obtain).
for i=1:49
pcolor( Xp,Yp,hs(i))



KSSV 2022-5-30
s = struct2cell(hs) ;
N = length(s) ;
for i = 1:N

更多回答(0 个)


Help CenterFile Exchange 中查找有关 Structures 的更多信息




Community Treasure Hunt

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

Start Hunting!

Translated by