MATLAB: Trying to write a function with random, input and fprint

doit4mefprintfinputno attemptrandom

I am trying to write a function that asks for names, for example it should first ask, What are the names of the players. Then is should pick one name with rand and decide if the player should play goalkeeper, defencer, midfielder og striker. Then it should print out for example… David is going to play as a striker. I have tried everything but i dont get it to work!

Best Answer

Try it this way:
Nafn={'Arnar' 'Hlynur' 'Ingimar' 'Stebbi'};
Drykkur={'Bjór' 'Skot' '2 sopar' 'Ekkert' '1 sopi' 'Hálfur bjór'};
button = menu('Enter a player name', Nafn);
message = sprintf('%s is a %s', Nafn{button}, Drykkur{button});
uiwait(msgbox(message));