You need to assign both defined return values for your function in every possible path.
Output argument 'pos' is not assigned on some execution paths
tells you exactly the problem. The same also applies for neg
by the way.
function [pos, neg] = select_output(err)
% if the error is negative , flow through the PID designed for negativ
% errors otehrwise positiv
if err >= 0
pos=err;
neg = 0;
else
pos = 0;
neg=err;
end
I don't know if assigning 0 to the variable that is not affected by your if-condition is feasible but in the end you need to assign both return values.