Restart script when user says yes
Afficher commentaires plus anciens
Hi,
I have a while statement at the end of my code asking if they would like to select another choice to repeat the code, however I cannot get it to begin from the beginning of the script again, and so just repeats itself.
My code:
function [m] = AnotherTeam
while(1)
m = input('Do you want to choose a different team, Y/N [Y]:','s');
if m == 'N'
break
elseif m == 'Y'
[team] = choose_team;
end
end
end
Is there a way to get this to restart the code from a specific point
Many thanks in advance for any feedback
2 commentaires
Geoff Hayes
le 11 Fév 2021
Jake - you may need to show more of your code so that we can get an idea of what you mean by ..begin ffom the beginning of the script again. What is the beginning? Outside of the while loop or somewhere else? If the user selects N then (from what I can see) you break out of the while loop. But where do you want to "go" if the user says Y.
Jake keogh
le 11 Fév 2021
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scripts dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!