repeat function and calculation
8 次查看(过去 30 天)
显示 更早的评论
here is my code
x=('input x')
y=x^+2
how do I ask once I get my output if I want the calculation to be repeated again
回答(1 个)
Ameer Hamza
2020-3-8
This is a general structure of what you are trying to do
condition = true;
while condition
x = input('Enter a number: ');
y = x.^2;
disp(y);
condition = input("Do you want to continue? (yes/no)\n", 's') == "yes";
end
0 个评论
另请参阅
类别
在 Help Center 和 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!