Help in fzero function

1 view (last 30 days)
Manal KOUIHI
Manal KOUIHI on 16 Feb 2021
Commented: Walter Roberson on 18 Feb 2021
Hi
I want to use the function fzero for modeling PV Cell, but i have a problem about the line (I=fzero(fun,I0))
they display me : Error in fzero
  2 Comments
Walter Roberson
Walter Roberson on 16 Feb 2021
Not enough information to go on. We need your code to test with.
Manal KOUIHI
Manal KOUIHI on 16 Feb 2021
Thanks for your answer,

Sign in to comment.

Accepted Answer

Walter Roberson
Walter Roberson on 16 Feb 2021
You should not have named your function fzero.m -- doing that interferes with calling the MATLAB fzero function.
  2 Comments
Manal KOUIHI
Manal KOUIHI on 16 Feb 2021
This is my code
clear all
k =1.8065e-23; %boltzman constant
q=1.602e-19; %charge of electron
Iscn=8.21; %Nominal SC Current
Vocn=35; %Nominal OC Voltage
kv=-0.1230; %Temperature voltage constant
Ki=0.0032; %Temperature current constant
Ns=54; %No.of series connected cells
T=25+273; %Opreating temperature
Tn=25+273; %Nominal temperature
Gn=1000; %Nominal Irradiance
a=1.3; %diode Ideality constant
Eg=1.12; %Band gap of silicon at 25 degree celcius
G=1000; %actual Irradiation
Rs=0.221;
Rp=415.405;
%Reverse saturation current
Vtn=Ns*(k*T/q);
Ion=Iscn/((exp(Vocn/(a*Vtn)))-1)
%Saturation current
Io=Ion*((Tn/T)^3)*exp(((q*Eg/a*k))*((1/Tn)-(1/T)));
%Photo current
Ipvn=Iscn;
Ipv=(Ipvn+Ki*(T-Tn))*(G/Gn);
Vt=Ns*(k*Tn/q);
%The current output of PV moduleThe current output of PV module
I0=5;
fun = @(I)(I-(Ipv- Io*(exp((V+(I*Rs))/(Vt*a))-1))-((V+(Rs*I)/Rp)));
I= fzero(fun,I0)
hold on
figure (1)
plot(V,I);
Walter Roberson
Walter Roberson on 18 Feb 2021
Your code never assigns to V, but uses it in fun() and also uses it in plot()
Note that fzero() can only output a scalar in any one call, so your I would be a scalar if the all works. Also, the function you pass to fzero() must return a scalar. Your function uses all of V in a way that the output is going to be the same size as V, so your V would have to be a scalar too.
Then you get down to plot(V,I) but both of them are scalars. When you plot() a scalar, no line will be generated, and if you do not specify a marker, no marker will be drawn either.
My guess is that you want something like:
V = linspace(-5, 10);
funV = @(I,v)(I-(Ipv- Io*(exp((V+(I*Rs))/(Vt*a))-1))-((v+(Rs*I)/Rp)));
I = arrayfun(@(v) fzero(@(I) funV(I,v), I0), V);
plot(V, I)

Sign in to comment.

More Answers (1)

Manal KOUIHI
Manal KOUIHI on 16 Feb 2021
I changed the name of the file but still same problem

Categories

Find more on MATLAB in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!