For/While/If loop question
Show older comments
Hey there I have a range of values from 0-10 and for different ranges there will be different relations for example lets say x=0:10 and when x<3 than x2=x^2+2x and when 3<=x<7 than x2=x^4-x^8+44x and than another relation for the rest i'm wondering how I'd write the loop for it.
This is what I was thinking x=0:10;
while x<.3 x2=x^2+2x end
while 3<=x<7 x2=x^4-x^8+44x end
fprintf('x2')
although maybe a while loop nested in a for loop could work if that makes sense
1 Comment
Jan
on 28 Nov 2018
@David: It is impolite to remove the text of the question, after somebody has spent the time an effort to post an answer. If you proceed to do this, your chances to get answers for your future questions will shrink.
Accepted Answer
More Answers (0)
Categories
Find more on Code Performance 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!