MATLAB: Str in a IF statement, PLEASE HELP

forifstrstring

Thats what I asked to do.
This is my code so far. But its not working for the str and complex part. Can anyone kindly help me?
p = input('To play the game, enter a shooting angle between -90 and 90 degree: ');
for i = 1 : p
if p(i) <= -90 || p(i) >= 90
disp('Enter a real number between -90 and 90 degree!!!');
break
elseif p(i) == 'str'
disp('Enter a real number between (-90~90) rather than string');
break
elseif p(i) == 'complex'
disp('Enter a real number between (-90~90) rather than any complex number')
break
end
end

Best Answer

Hi ,
Try Isstr to detect a string and isreal to detect a real number or complex number
for i = 1 : p
if p(i) <= -90 || p(i) >= 90
disp('Enter a real number between -90 and 90 degree!!!');
break
elseif isstr(p(i))
disp('Enter a real number between (-90~90) rather than string');
break
elseif isreal(p(i))==0
disp('Enter a real number between (-90~90) rather than any complex number')
break
end
end