Permalink
Cannot retrieve contributors at this time
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?
5011CEM-Resit/menu.m
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
16 lines (12 sloc)
494 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%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 |