repeat function and calculation
11 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
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 commentaires
Réponses (1)
Ameer Hamza
le 8 Mar 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
0 commentaires
Voir également
Catégories
En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!