MATLAB: Move to next selection

choicecontinuehelphowMATLABmenumenu functionmove onmultiplemultiple choiceselectionskip

hi all, I am wanting matlab to move to the next multi choice question if the chosen answer is "No"
eg:
choice = menu("Do you want to see the opening times of this recycling centre?","Yes","No")
if choice == 1
new_data(selectedplaceindex,1:3)
elseif choice == 2
%THIS IS THE LINE i STRUGGLE WITH
end
choice2 = menu("Do you want to navigate there?","Yes","No")
if choice2 == 1
new_data(selectedplaceindex,4)
elseif choice2 == 2
menu("Thank you, keep recycling!")
end
this is the selection process I want however, after "choice" is chosen, if "choice == 2" i want matlab to forget that selection and move on. equally with choice ==1 but i think that works anyway.

Best Answer

so you don't need to place an else in the first:
choice = menu("Do you want to see the opening times of this recycling centre?","Yes","No")
if choice == 1
new_data(selectedplaceindex,1:3)
end
choice2 = menu("Do you want to navigate there?","Yes","No")
if choice2 == 1
new_data(selectedplaceindex,4)
elseif choice2 == 2
menu("Thank you, keep recycling!")
end
Related Question