How to solve this problem [Output argument 'fever' is not assigned on some execution paths]?

1 view (last 30 days)
I've been in this problem almost three months. I don't know what to do anymore.
I just want the output to display according to the condition given. If y > 3.74, display the value of fever. If y < 3.74, display the value of notfever. But because of the errors, I cannot proceed.
It is an honoured if anybody could help me to solve this error. here I attach the code that I'm used in Matlab function block.
function [fever,notfever] = detection(y)
if y > 37.4
fever = y;
else y < 37.4
notfever = y;
end
end

Accepted Answer

Walter Roberson
Walter Roberson on 5 Oct 2016
In your code, what should be assigned to fever if y is not > 37.4 ? What should be assigned to notfever if y is not < 37.4?
Your code has to be written to assign something to each of the output variables. Even if it ends up looking like
function [fever,notfever] = detection(y)
if y > 37.4
fever = y;
notfever = inf;
else y < 37.4
notfever = y;
fever = inf;
else
fever = inf;
notfever = inf;
end
end

More Answers (0)

Categories

Find more on MATLAB 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!