MATLAB: How to make if accept letters

ifMATLAB

i know about 'if' code, but what i dont understand is why it tells me error?
error: 'y' undefined near line 33 column 16
error: called from
Code_6 at line 33 column 5
nam = input('Enter name: ', 's');
adrs = input('Enter address: ', 's');
num = input('Enter amount of purchase: $');
pur = input('Enter type of purchase (L for Laptop / D for Desktop): ', 's');
fprintf('\n')
switch pur
case {'L' 'l'}
disp('You have choosen Laptop as your type of puchase')
if num <250
disc = (0 / 100) * num;
net = num - disc;
elseif num <570
disc = (5 / 100) * num;
net = num - disc;
elseif num <1000
disc = (7.5 / 100) * num;
net = num - disc;
elseif num >1000
disc = (10 / 100) * num;
net = num - disc;
endif
fprintf('Name: %s\n', nam)
fprintf('Address: %s\n', adrs)
fprintf('Net amount: $%.2f \n', net)
#promt user to continue or not
yesno = input('Do you wish to continue purchase? (y/n)', 's')
fprintf('\n')
if yesno = y;
Code_6
else
disp('You have exit purchase screen, Goodbye.')
endif

Best Answer

Several problem:
1. = is an operator for assignment in MATLAB. For comparison, you need to use ==
if yesno == y
2. You want to compare the value to character 'y', just writing y means that you are referring to a variable
if yesno == 'y'
3. It is more of a suggestion, but it us better to use strcmp() for char arrays
if strcmp(yesno,'y')