How to continue to loops
이전 댓글 표시
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
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
