repeat function and calculation
Ältere Kommentare anzeigen
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
2 Kommentare
Ameer Hamza
am 8 Mär. 2020
Which calculation do you want to repeat?
matt noman
am 8 Mär. 2020
Antworten (1)
Ameer Hamza
am 8 Mär. 2020
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
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!