Multiple conditional statements and a for loop.
Show older comments
i have a for loop that calls a function and the if statements are supposed to determine when the function gets within a certain range, byut i am unsure if i need the statements to be nested within each other it to split them up. heres some of the code:
for i = 1:npoints
t(i)=(i-1)*tmax/npoints;
x(i) = sec_ord(wn, zeta, t(i));
end
if sec_ord(wn, zeta, t(i))<1.02
if sec_ord(wn, zeta, t(i))>0.98
if flag==1
t=t+inc;
elseif flag==0
flag=1;
tss=t;
t=t+inc;
if t<=tmax
sec_ord(wn, zeta, t(i));
elseif flag==1
tss=set_time;
end
end
else
flag=0;
t=t+inc;
end
end
after this runs i want to be able to use some of the values(such as tss and set_time) set inside the if statements but they do not get stored.
Any help would be appreciated,
thanks.
1 Comment
Harshit Jain
on 7 Feb 2019
Just wanted to ask if the "if" statement is even working, since it is outside the "for" loop and t(i) would give error there. Also, I would appreciate if you would elaborate the question a little bit more.
Accepted Answer
More Answers (0)
Categories
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!