Simulink: Output argument 'mot_trq_dem' is not assigned on some execution paths

1 次查看(过去 30 天)
I am actually running a Matlab code related to Energy management strategy in Hybrid Electric Vehicle. I have a matlab function block in simulink which is showing this as error. I am trying for past 2days to debug this error as which condition of 'mot_trq_dem' I am missing but unable to debug it and because of this I am also gettig error as Errors occurred during parsing of MATLAB function 'XYZ'
Can anybody Kindly help me in this regard ??
I am posting my part of the code below:
% INPUT
%trq_demand : instantaneous torque demand
%spd_demand : instantaneous speed demand
%soc : SOC measurement
%clutch1_pos: Clutch1 position either 1 (on) or 0(off)
%% OUTPUT
%mot_trq_dem: motor torque demand
%eng_trq_dem: engine torque demand
%% CASE 1 : Net Torque demand is negative (trq_demand<0)
if ((trq_demand <=0) && (abs(trq_demand)<abs(mot_trq_min)))
if(clutch1_pos==0)
eng_trq_dem=0;
mot_trq_dem=trq_demand ;
brake_trq=0;
elseif(clutch1_pos==1)
eng_trq_dem=interp1(f_tbrake_n_bpt,f_tbrake_min ,spd_demand,'pchip');
mot_trq_dem=trq_demand-eng_trq_dem ;
brake_trq=0;
end
end
if ((trq_demand <=0)&& (abs(trq_demand)>=abs(mot_trq_min)))
if(clutch1_pos==0)
mot_trq_dem=mot_trq_min ;
eng_trq_dem=0 ;
brake_trq=trq_demand-mot_trq_dem-eng_trq_dem ;
elseif(clutch1_pos==1)
eng_trq_dem=interp1(f_tbrake_n_bpt,f_tbrake_min ,spd_demand,'pchip');
mot_trq_dem=mot_trq_min ;
brake_trq=trq_demand-mot_trq_dem-eng_trq_dem ;
end
end
%% CASE 2 : Net Torque demand is positive (trq_demand>0)
if(trq_demand >0 && clutch1_pos==0)
if(trq_demand >=mot_trq_max)
mot_trq_dem=mot_trq_max;
eng_trq_dem=0;
elseif(trq_demand < mot_trq_max)
mot_trq_dem=trq_demand;
eng_trq_dem=0;
end
end
if(trq_demand >0 && clutch1_pos==1)
.................
''''''''''''''''''''''''related code
''''''''''''''''''''''''''
mot_trq_dem=mot_trq_vec(x) ; %corresponding motor torque demand for min fuel consumption
eng_trq_dem=eng_trq_vec(x) ; %corresponding engine torque demand for min fuel consumption
end
Kindly Help me at the earliest as to which condition I have missed.
Regards
Ajay Kumar

回答(1 个)

Abdolkarim Mohammadi
Maybe adding an empty else to each if helps. For example:
if ...
...
else
end

类别

Help CenterFile Exchange 中查找有关 Green Vehicles 的更多信息

产品


版本

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by