Borrar filtros
Borrar filtros

Hello. I'm using the following code in embedded matlab in simulink. And I,m getting the message that Variable 'D' is not fully defined on some execution paths. And i don't kno

1 visualización (últimos 30 días)
function D = improvedFOCV(VA, G, T)
persistent VocSTC
persistent K1
persistent Ctv
persistent Cgv
persistent Kv
persistent Bt
persistent Ag
persistent Voc
persistent Dprev
if isempty(Bt)
Bt=0.0016;
end
if isempty(Ag)
Ag=0.006;
end
if isempty(VocSTC)
VocSTC=37.6;
end
if isempty(Kv)
Kv=-0.35;
end
if isempty(K1)
K1=0.78;
end
if isempty(Dprev)
Dprev=0.5;
end
Ctv = 1+(Kv/VocSTC)*(T-25);
Cgv = 1+((Bt*Ag)*(G-1000));
Voc=Ctv*Cgv*VocSTC;
Vmpp=K1*Voc;
DeltaVA=Vmpp-VA;
if (DeltaVA<0)
D =Dprev+0.0001;
elseif(DeltaVA>0)
D=Dprev-0.0001;
end
if D>=0.9
D=0.9;
elseif D<0
D=0;
end
Dprev=D;

Respuesta aceptada

Benjamin Thompson
Benjamin Thompson el 8 de Abr. de 2022
If DeltaVA could evaluate to zero then D will not be defined. If you want to be sure D is defined, then initialize it to a good value at the beginning of your code.
  1 comentario
Tarun Reddy Pashya
Tarun Reddy Pashya el 8 de Abr. de 2022
I have tried evaluating D to zero and gave a condition. But still I can see the same error and some other errors like Errors occurred during parsing of MATLAB function 'improveddFOCV/MATLAB Function. Can you please help me? If you're willing to help, do share you're email id or email me to tarunpashya@gmail.com.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

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

Community Treasure Hunt

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

Start Hunting!

Translated by