For loop through structure

1 Ansicht (letzte 30 Tage)
Katherine
Katherine am 2 Apr. 2014
Kommentiert: dpb am 2 Apr. 2014
I have a structure named sacfile which has data for various stations within it (sta1-sta6). The sacfile is further borken up into day increments (sacfile.day, per station), and further into hourly increments for each day (sacfile.day.hour). I would like to loop through each day and subsequently through each hour for each station comparison (i.e., day 032 loop through sta1 hr 1 compared to sta2 hr 1, sta3 hr 1, sta4 hr1, sta5 hr1, sta6 hr 1, and so on and so forth through all the hours of that day, then move onto the next day, etc. You get the point. The stations are defined in sacfile.sta. Does anyone have any suggestion on how I can do this simply?
*I only want to loop through the same day and hour for the stations, then move onto the subsequent day and hour. I don't want to cross compare different days and hours. This is important for the loop.
I tried the following:
for i = 1:length(sacfile)
for j = 1:length(sacfile(i,1).day)
for h = 1:length(sacfile(i,1).day.hour)
Will this work, how can I be assured it's looping through the correct days, i.e., that day 1 for sta1 is the same day1 for sta2 and it's not intermixing them?
  1 Kommentar
dpb
dpb am 2 Apr. 2014
...how can I be assured ... that day 1 for sta1 is the same day1 for sta2 ...?
That's all dependent upon the data in the file -- if it's possible they don't all have the same DOM data and you need that to be so, then you'll have to keep track of which day is in which; there's no automagic way to tell that a priori.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Characters and Strings finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by