Help in fzero function

조회 수: 1 (최근 30일)
Manal KOUIHI
Manal KOUIHI 2021년 2월 16일
댓글: Walter Roberson 2021년 2월 18일
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
Walter Roberson
Walter Roberson 2021년 2월 16일
Not enough information to go on. We need your code to test with.
Manal KOUIHI
Manal KOUIHI 2021년 2월 16일
Thanks for your answer,

댓글을 달려면 로그인하십시오.

채택된 답변

Walter Roberson
Walter Roberson 2021년 2월 16일
You should not have named your function fzero.m -- doing that interferes with calling the MATLAB fzero function.
  댓글 수: 2
Manal KOUIHI
Manal KOUIHI 2021년 2월 16일
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 2021년 2월 18일
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)

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Manal KOUIHI
Manal KOUIHI 2021년 2월 16일
I changed the name of the file but still same problem

카테고리

Help CenterFile Exchange에서 MATLAB에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by