简体   繁体   中英

Creating new structure variables for each iteration in a loop

I have a function which assess a time series of data over a particular range within that time.

The output of the function is a structure array. The function is performed over a given range of time eg 0 to 15 seconds. I would like to produce iterate this so that I can get the results for the each time interval. Eg structure 1 = 0 to 15 seconds; structure 2 = 15 to 30 seconds and so on.

So far this is what I have but I am unable to save/get the results for each iteration, on the last one (eg 15 to 30):

for i = 1:2    
    while n<30
       y(i) = function(n n+15);    
       n=n+15;
    end
end

Use an array and simple if statement:

if mod(i, 15) == 0  
   do something

Every value can be stored separately in an array. Array index is being incremented in the if condition.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM