Can I nest an if statement in a for loop?
Question as above, supposedly the following code uses an illegal use of a reserved keyword (if), why is this?
for k = [x3,…,xN]
k == 0.5*(x1+x2);
if sign(f(k)) == sign(f(x1))
k = x1;
else
k=x2;
end
endQuestion as above, supposedly the following code uses an illegal use of a reserved keyword (if), why is this?
for k = [x3,…,xN]
k == 0.5*(x1+x2);
if sign(f(k)) == sign(f(x1))
k = x1;
else
k=x2;
end
end Question as above, supposedly the following code uses an illegal use of a reserved keyword (if), why is this?
for k = [x3,…,xN]
k == 0.5*(x1+x2);
if sign(f(k)) == sign(f(x1))
k = x1;
else
k=x2;
end
end if statement, for loop MATLAB Answers — New Questions