Hi, I need help with a code I'm trying to run.
I'm trying to run it so you have 3 chances to guess a string variable correctly, and after the third, it says incorrect, or if any of the guesses are correct then the code ends and just says you have guessed correctly.
The code is shown below that I am using: (The error shown is that Matrix dimensions must agree – the code runs perfectly with correct guesses or when I guess food which has 5 letters)
FavFood=('Pizza');y=input('What is my favourite Food? ','s');if y==FavFood disp('Well done, you guessed correctly');else x=input('Sorry, you guessed wrong. Try again: ','s'); if x==FavFood disp('Well done, you guessed correctly'); else z=input('Sorry, you guessed wrong. Try again: ','s'); if z==FavFood disp('Well done, you guessed correctly'); else disp('Sorry, you ran out of chances.'); end endend
Many thanks,
EDIT: typo
Best Answer