Here is an example of some simple code I have written. When I ask the user for a yes/no answer it works for yes but gives an error when they enter no (matrix dimensions do not agree). However it does work if the input is only a y or n. Why is this?
a = 'no';
while a ~= 'yes'
a = input('Do you like the colour red? (yes/no) ——> ','s');if a == 'yes' disp('Good its the best colour ever')elseif a == 'no' disp('Whats wrong with you?... TRY AGAIN')else disp('Thats not an answer, enter y for yes or n for no.')end
end
THANKS!!
Best Answer