For/While/If loop question
显示 更早的评论
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 个评论
Jan
2018-11-28
@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.
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Code Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
