How to solve this ERROR: Output argument "psi" (and maybe others) not assigned during call to "...".

1 回表示 (過去 30 日間)
Hello,
I'm using a simulink model with a Matlab FCN block and have this persistent ERROR:
*Output argument "psi" (and maybe others) not assigned during call to "blocoControlador2".*
I've already read about this error and still can't understand why continues.
The code:
function [psi] = blocoControlador2( il_in,il_k,psi_in,psi_k )
a= 7.3421E-6;
b= 6.2343;
c= 457.8311;
d= 25.1627;
Icc= 10;
Isat= 694;
N= 350;
%psi=0; % !?!?!?!?
%state=0;
Af=(Isat/N)/(cos((pi/2)*((Isat/N)/Icc)));
Bf=(pi/2)*(1/Icc);
f= Af*cos(Bf*il_in);
caract= a*N*il_in + (b*N*il_in)./(c+d*N*abs(il_in));
lambAsc= a*N*(il_in-f) + (b*N*(il_in-f))./(c+d.*N*abs(il_in-f));
lambDesc = a*N*(il_in+f) + (b*N*(il_in+f))./(c+d*N*abs(il_in+f));
if il_in>il_k && il_in<=(Isat/N)&& psi_in==0
psi=0;
state=0;
end
if il_in>il_k && il_in>(Isat/N) && psi_in< lambAsc && state==0
psi= psi_k;
end
if il_in>il_k && il_in>(Isat/N) && psi_in>=lambAsc
psi=lambAsc;
state=1;
end
end
Basically, I want to initialize "psi" just inside the IF.
If I initialize the variable on the firsts lines (psi=0;) the error disappears but my test conditions will fail.
Is there any way to initialize this variable with a value just for the first time? Like an "initial condition". Because I need to declare "state" inside the IF's too. Same situation.
Thanks in advance!

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 4 月 1 日
編集済み: Azzi Abdelmalek 2014 年 4 月 6 日
When all the conditions don't match, the variable psi is empty, maybe you should initialize your variable psi to what is needed
  1 件のコメント
F
F 2014 年 4 月 5 日
Thanks!!
I add an "else" statement for when all the conditions don't match and it worked.
if... elseif.. elseif... else..

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by