Restart script when user says yes
古いコメントを表示
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 件のコメント
Geoff Hayes
2021 年 2 月 11 日
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
2021 年 2 月 11 日
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Scripts についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!