return to start of code

조회 수: 22 (최근 30일)
James Webber
James Webber 2022년 1월 5일
댓글: Voss 2022년 1월 5일
i have code like this
case 2
s=input ('would you like to see the game stastics 1,yes 2,no:')
switch s
case 1
num_player = 20;
WLT = zeros(num_player,3);
%...
if have_a_winner
WLT(winner_index,1) = WLT(winner_index,1) + 1;
WLT(loser_index,2) = WLT(loser_index,2) + 1;
else
WLT(player1_index,3) = WLT(player1_index,3) + 1;
WLT(player2_index,3) = WLT(player2_index,3) + 1;
end
%disp('stastics')
case 2
if s== 2
disp('main menu')
playon=false;
end
end
it asks questions and wehn i want to enter no i would like my code to restart the whole program form the beginging i have tried this but it doees not work
case 2
if s== 2
disp('main menu')
playon=false;
end
i have multiple switch case throught my code and this is the only one that i would like it to take you back to the beginging.
  댓글 수: 1
Voss
Voss 2022년 1월 5일
Put the whole thing inside a while loop, and when you want to go back to the beginning call continue.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Strategy & Logic에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by