My textbook gave me code that has an error I don't know how to fix
1 view (last 30 days)
Show older comments
if flag==1 && alt>=30000
fprintf('Normal operation at %0.0f feet.\n',alt)
elseif flag==0 || alt==0
fprintf('On Ground')
elseif flag==2 && alt < 30000
fprintf('Currently at %0.0f feet and climbing\n',alt)
elseif flag==3
fprintf('Currently at %0.0f feet and descending\n',alt)
else
fprintf('Status transitional')
end
Please here is the code!
This is the error I'm getting
Operands to the || and && operators must be convertible
to logical scalar values.
Error in Homework4q5 (line 3)
if flag==1 && alt>=30000
0 Comments
Accepted Answer
Catalytic
on 27 Mar 2019
Edited: Catalytic
on 27 Mar 2019
alt and flag must be scalars.
3 Comments
Catalytic
on 27 Mar 2019
Edited: Catalytic
on 27 Mar 2019
It's not giving me any problems.
flag = 1; alt = 25000;
if flag==1 && alt>=30000
fprintf('Normal operation at %0.0f feet.\n',alt)
elseif flag==0 || alt==0
fprintf('On Ground')
elseif flag==2 && alt < 30000
fprintf('Currently at %0.0f feet and climbing\n',alt)
elseif flag==3
fprintf('Currently at %0.0f feet and descending\n',alt)
else
fprintf('Status transitional')
end
disp ' '
Running this gives me
Status transitional
More Answers (0)
See Also
Categories
Find more on Multirate Signal Processing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!