For cycle over a struct array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Tiziano Bagnasco
el 30 de Mayo de 2022
Comentada: Tiziano Bagnasco
el 30 de Mayo de 2022
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 comentarios
Voss
el 30 de Mayo de 2022
"I know how to extract the matrices one by one from the struct array"
Can you show how you do this? I ask because the situation is a little confusing to me. For example, "a 1x1 struct array" is a scalar struct. If it "contains 49 matrices", does that mean the struct has 49 fields, with each field being one matrix? Probably seeing the code you have so far would help to answer those kinds of questions.
Respuesta aceptada
KSSV
el 30 de Mayo de 2022
s = struct2cell(hs) ;
N = length(s) ;
for i = 1:N
pcolor(XP,Yp,s{i})
drawnow
end
Más 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!