Skip to content
Permalink
c3c98ca846
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
16 lines (12 sloc) 494 Bytes
%%I learnt how to do this from https://www.youtube.com/watch?v=zLb4ZHFfbO0
%%Function definition here
function menuchoice = displayMenu(choices)
%%Loop to go over the length of choices and print them (passed in as an array/list)
for i = 1:length(choices)
fprintf('%d. %s\n', i, choices{i});
end
menuchoice = 0
%%While loop to keep asking for input until a valid number is selected
while ~any(menuchoice == 1:length(choices))
menuchoice = validnum('Please choose a menu item: ')
end