How to solve this ERROR: Output argument "psi" (and maybe others) not assigned during call to "...".
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
F
am 1 Apr. 2014
Bearbeitet: Azzi Abdelmalek
am 6 Apr. 2014
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!
0 Kommentare
Akzeptierte Antwort
Azzi Abdelmalek
am 1 Apr. 2014
Bearbeitet: Azzi Abdelmalek
am 6 Apr. 2014
When all the conditions don't match, the variable psi is empty, maybe you should initialize your variable psi to what is needed
Weitere Antworten (0)
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!