What wrong with my code? anyone can help?

1 次查看(过去 30 天)
Hello sir.
This is my code
SDR = 0.11
Cx=184
Pmp_stc = PV_module(10,2)
Vbatt = Battery(1,1)
Ebatt_min = (1-DODMax).*(Cbatt.*Battery(1,1))
Ebatt_max=Cx*Vbatt
Ebatt=Ebatt_max
for n =1:16992
if n==1
Ebatt_cal=Ebatt_min
LPS=0
SOC=Ebatt_cal/(Cx*Vbatt)
else
if Ebatt(n-1)<Ebatt_max
Esys=Pmp_stc.*Nt_PV.*Ftemp.*Irradiation5M(n,7).*Fmm.*Fdirt.*Eff_inv*Eff_PV_cable
if EsysN>Irradiation5M(n,7)
LPS=0
Ebatt_cal=(Ebatt_max(n-1).*(1-(0.11/100)))+((Esys-(Load_profile(n,3)./Eff_inv)))
if Ebatt_cal>Ebatt_max
Ebatt_cal=Ebatt_max
else
Ebatt_cal=Ebatt_cal
end
SOC=Ebatt_cal/(Cx*Vbatt)
else
Ebatt_cal=(Ebatt(n-1).*(1-(SDR/100)))-((Load_profile(n,3)/Eff_inv)-EsysN)
if Ebatt_cal<Ebatt_min
Ebatt_cal=Ebatt_min
else
Ebatt_cal=Ebatt_cal
end
LPS=((Load_profile(n,3))- ((EsysN+Ebatt(n-1))-Ebatt_min).*Eff_inv)
if LPS<=0
LPS=0
else
LPS=LPS;
end
SOC=Ebatt_cal/(Cx*Vbatt)
end
else
Ebatt(n-1)>=Ebatt_max
Esys=0
Ebatt_cal=(Ebatt(n-1).*(1-(0.11/100)))-((Load_profile(n,3))./(Eff_inv-EsysN))
if Ebatt_cal<Ebatt_min
Ebatt_cal=Ebatt_min
else
Ebatt_cal=Ebatt_cal
end
LPS=(Load_profile(n,3))-((Esys+Ebatt(n-1))-Ebatt_min).*Eff_inv
if LPS<=0
LPS=0
else
LPS=LPS
end
SOC=Ebatt_cal/(Cx*Vbatt)
end
end
Jawapan=[Ebatt_cal SOC LPS]
if n==l
Jawapan1=Jawapan;
else
Jawapan1=[Jawapan1;Jawapan]
end
Ebatt=Jawapan1(:,1);
LPSrec=sum(Jawapan(:,3));
end
SOCcur=-Jawapan1(:,2);
if barisa==1
SOCall=SOCcur;
else
SOCall=[SOCall SOCcur];
end
LPSP=LPSrec/((Eac1*66)+(Eac2*26))
matlab show error
Undefined function or variable 'l'.
Error in CASE1_LPSP (line 105)
if n==l
i already check all the line but did not find the problem.pls help.
anyone can show me the the simpler code or better way to code this ? thank you so much.

回答(1 个)

Voss
Voss 2021-11-23
That line is "if n == l" with a lower-case L, which is not a defined variable, evidently. Maybe it should be "if n == 1", with the number one (1).

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

标签

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by