I am trying to a) Create a script with if & elseif statements that will output one of three statements given three potential conditions:
1) If X & Y are < 3 but > 0: output the statement ‘X and Y are Less than 3 but greater than 0’.
2) If X and Y are less than 0: output the statement ‘X and Y are negative’
3) If X or Y are > 3: output ‘Either X or Y is greater than 3’. And lastly if none of the above conditions are met, output ‘None of the three conditions have been met’.
Where x=-0.5, y=-2
my script:
>> x=-0.5,y=-2if x < 3 && y < 3 && x >0 && x>0disp (‘X and Y are Less than 3 but greater than 0’)elseif X<0 && Y<0disp (‘X and Y are negative’)elseif X>3 || Y>3disp (‘Either X or Y is greater than 3’)elsedisp (‘None of the three conditions have been met’)endx = -0.5000y = -2
My display is wrong:
disp (‘X and Y are Less than 3 but greater than 0’) | Here is my error: Error: The input character is not valid in MATLAB statements or expressions.
Best Answer