フィルターのクリア

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

1 回表示 (過去 30 日間)
AJAY KUMAR
AJAY KUMAR 2021 年 4 月 8 日
回答済み: Abdolkarim Mohammadi 2021 年 4 月 9 日
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
Abdolkarim Mohammadi 2021 年 4 月 9 日
Maybe adding an empty else to each if helps. For example:
if ...
...
else
end

カテゴリ

Help Center および File ExchangeGreen Vehicles についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by