How to write a Loop for this case?
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello all,
I have one 1x1 struct with 34 field inside it. regarding the picture below, I would like to concatenation:
C= cat(3, y1982, y1983, y1984, ..., y2015)

how to do it?
thank you
0 commentaires
Réponse acceptée
Guillaume
le 28 Oct 2019
Creating these numbered fields was a bad idea in the first place.Numbered or sequentially named variables or fields always make the code more complicated. If possible, i'd go back to the code that created them and change that.
Failing that, the easiest:
ctemp = struct2cell(precp_monthly); %convert struct into cell array
c = cat(3, ctemp{:}); %concatenate fields into 3D matrix
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Structures dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!