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 次查看(过去 30 天)
显示 更早的评论
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;
0 个评论
采纳的回答
Benjamin Thompson
2022-4-8
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 个评论
Tarun Reddy Pashya
2022-4-8
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Install Products 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!