How to continue to loops
Afficher commentaires plus anciens
HI
One thing that I want to do is after first if I want to continue to sum the values in arrival in period between 100 and 200 and and other periods but I don't know how to do that and how to define 'i 'where to start after first if . I want only to sum the values in that period . first if is ok but I don't know how to continue
arrival=xlsread('tripinfo.xlsx','G:G');
depart_time=xlsread('tripinfo.xlsx','B:B');
for i = 1:1:91
if depart_time(i) < 100
mean_travel1 = sum(arrival(1:i,1));
elseif 100 < depart_time(i) & depart_time(i)< 200
mean_travel2 = sum(arrival(i,1));
elseif 200 < depart_time(i) & depart_time(i) < 300
mean_travel3 = sum(arrival(i,1));
elseif 300 < depart_time(i) & depart_time(i) < 400
mean_travel4 = sum(arrival(i,1));
elseif 400 < depart_time(i) & depart_time(i) < 500
mean_travel5 = sum(arrival(i,1));
else
mean_travel6 = sum(arrival(i,1));
end
end
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
