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

1 visualización (últimos 30 días)
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!

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 1 de Abr. de 2014
Editada: Azzi Abdelmalek el 6 de Abr. de 2014
When all the conditions don't match, the variable psi is empty, maybe you should initialize your variable psi to what is needed
  1 comentario
F
F el 5 de Abr. de 2014
Thanks!!
I add an "else" statement for when all the conditions don't match and it worked.
if... elseif.. elseif... else..

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Simulink en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by