I am trying to solve current equations of a pv cell using fsolve butit keeps showing error, can someone pls see what the error in my code is?

5 views (last 30 days)
Here is the main code:
clc;
clear all;
Pmpp = 50; %Max Power
Vmpp = 17.98; %Vol at Pmax
Impp = 2.77; %Current at Pmax
Isc= 3; %Short-circuit current
Voc= 22; %Open Circuit Voltage
a= 0.0004; %Temp coeff. of Isc
b= -0.0033; %Temp coeff. of Voc
T = 35;
Tref= 25;
S= 600;
Sref= 1000;
Rs= 0.085;
V= 30;
kref= (1-(Impp/Isc))^(1/(((Vmpp+Rs*Impp)/Voc)-1));
Vo = Voc*(1+ a*log(S/Sref)+ b*(T-Tref));
I= zeros(330,1);
Is = Isc*(1+a*(T-Tref))*(S/Sref);
for i = 1:330
V(i)= (i-1)*0.1;
fhandle = @fun4bisec;
[I]= fsolve(@(I) fhandle(I,V(i)));
y(i)= I;
end
plot(V,y),grid,hold on;
xlabel('Voltage'),ylabel('Current');
The code for function fun4bisec is:
function fval1= fun4bisec(Is,kref, Vo,Rs, Voc)
fval1= I(i) -Is*(1-kref.^((V(i)-Vo+Rs*I(i))/Voc));
end

Accepted Answer

Torsten
Torsten on 14 Mar 2023
clc;
clear all;
Pmpp = 50; %Max Power
Vmpp = 17.98; %Vol at Pmax
Impp = 2.77; %Current at Pmax
Isc= 3; %Short-circuit current
Voc= 22; %Open Circuit Voltage
a= 0.0004; %Temp coeff. of Isc
b= -0.0033; %Temp coeff. of Voc
T = 35;
Tref= 25;
S= 600;
Sref= 1000;
Rs= 0.085;
V= 30;
kref= (1-(Impp/Isc))^(1/(((Vmpp+Rs*Impp)/Voc)-1));
Vo = Voc*(1+ a*log(S/Sref)+ b*(T-Tref));
y= zeros(330,1);
Is = Isc*(1+a*(T-Tref))*(S/Sref);
I0 = 1.0;
for i = 1:330
V(i)= (i-1)*0.1;
fhandle = @fun4bisec;
[I]= fsolve(@(I) fhandle(I,V(i),kref, Vo,Rs, Voc),I0,optimset('Display','none'));
y(i)= I;
I0 = I;
end
plot(V,y),grid,hold on;
xlabel('Voltage'),ylabel('Current');
function fval1= fun4bisec(Is,V,kref, Vo,Rs, Voc)
fval1= Is -Is*(1-kref.^((V-Vo+Rs*Is)/Voc));
end

More Answers (0)

Community Treasure Hunt

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

Start Hunting!