I'm solving a simple problem (taken straight from a midterm review powerpoint slide), and to verify that my answer was correct, I put the code into MATLAB and it keeps giving me 'invalid use of operator' errors and I'm not quite sure why.
Additionally, the latter parts of each print statement are written in gold and aren't paired and I'm also confused about why that's happening.
a = 10; b = -5;
if (~(a*b)| (a==2*b))
fprintf(‘First!’);
elseif(a*b)
fprintf(‘Second!’);
elseif(a==-2*b)
fprintf(‘Third!’);
end
‘
and ’
are not a valid quote characters, you need to use '
. If you typed your MATLAB code into Word or some such editor with "smart quotes", your code will fail like this.
Replace all the single quotes in your code with the correct '
character and you're good to go.