フィルターのクリア

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;

採用された回答

Benjamin Thompson
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
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 ExchangeInstall Products についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by