Output argument is not assigned on some execution paths.

Hi,
My simulink function block have this code:
%Este bloco tem como função o ratreamento dos pontos pelos quais o robô
%deve passar e também o cálculo de e_theta, LAC e R TRACKING(e_theta,LAC,D,Stop)
function [e_theta,LAC,D,Stop] = gera_traj(goal,TRAJECTORY,x,y,theta)
% a ideia é para cada pronto ter um if.
aux = 1;
if TRAJECTORY(aux,1) < goal(aux,1)-0.03
Stop = 0;
d1 = (TRAJECTORY(aux,2)-y)/(TRAJECTORY(aux,1)-x);
thetad1= atan(d1);
d2 = (TRAJECTORY(aux,2)-y)/(TRAJECTORY(aux,1)-x);%Confirmar se é esse atg msm
thetad2 = atan(d2);
LAC = abs(thetad1)-abs(thetad2);
D = sqrt((TRAJECTORY(aux,2)-y)^2+(TRAJECTORY(aux,1)-x)^2);
e_theta = thetad1-theta;
else
aux= aux+1;
end
if TRAJECTORY(aux,1) == goal(aux,1)-0.03
Stop = 1;
end
end
And when i run it, i have this problem:
"Output argument 'e_theta' is not assigned on some execution paths."
How Can I fix it? Thanks

 Accepted Answer

Well, yes the error message is correct. If TTRAJECTORY(aux,1) is greater or equal to goal(aux,1)-0.03, the only thing your code does is increment aux+1 (if it's equal it also sets stop to 1) and then exit the function. So, indeed, e_theta never receives a value (neither does D or LAC for that matter).
I've no idea what your code is supposed to do so it's difficult to suggest a solution other than do assign a value to these variables (and to Stop if the value is strictly greater) in all branches. Perhaps, these if statement were meant to go inside a loop?

More Answers (0)

Categories

Find more on Simulink in Help Center and File Exchange

Asked:

on 12 Dec 2018

Answered:

on 12 Dec 2018

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!