Hi, my problem is when ı try to start these algorithm it's working. But when i try to change Rs value like different than 0 it's giving error.
"Error using plot. Non-numeric data is not supported in 'Line'"
I need to change value of Rs(manual), and I need to get I-V graph...
Thanks for helping
here is my code;
syms Vt Rp Rpmin Io Ipv V I Rp1 Pmax P Rs
Pmax=200.143;
Imp=7.61;
Vmp=26.3;
Iscn=8.21;
Vocn=32.9;
Ns=54;
q=1.60217646*(10^(-19));
K=1.3806503*(10^(-23));
ki=0.0032;
kv=-0.1230;
Tnom=298.15;
Gnom=1000;
a=1.3;
Vt=K*Tnom*Ns/q;
% for T G calculate Io , for Rs=0 Rpm,n
G=1000;
T=298.15;
Io=(Iscn+ki*(T-Tnom))/(exp((Vocn+kv*(T-Tnom))/(a*Vt))-1)
Rpmin= (Vmp/(Iscn-Imp))-((Vocn-Vmp)/Imp)
Rs=0;
Rp=Rpmin;
Ipvn= ((Rp+Rs)/Rp)*Iscn
Ipv=(Ipvn+ki*(T-Tnom))*(G/Gnom)
Rp1= (Vmp*(Vmp+Imp*Rs))/(Vmp*Ipv-Vmp*Io*exp(((Vmp+Imp*Rs)*q)/(Ns*a*K*T))+Vmp*Io-Pmax)
V=0:0.1:32.9;
I=Ipv-Io*exp((V+I*Rs)/(a*Vt))-((V+I*Rs)/Rp1)
plot(V,I)

 Réponse acceptée

John BG
John BG le 30 Juin 2017
Modifié(e) : John BG le 1 Juil 2017

6 votes

Hi Emircan
your script doesn't work for Rs>0 because as soon as Rs is not null, you are attempting to pass a vector and and an implicit function to command plot, where plot expects just 2 vectors, let me explain:
You may just plot with V alone
plot(V)
It works with any value of Rs, but then the X axis labels have to be re-tagged accordingly.
The problem lays in the line previous to plot
I=Ipv-Io*exp((V+I*Rs)/(a*Vt))-((V+I*Rs)/Rp1)
Note that you have I on both sides of the equal.
The only way for MATLAB to accept plot(V,I) is to either first solve that equation and pass the solved equation, or correct any possible error like perhaps the equation that you really need is
I=Ipv-Io*exp((V+Io*Rs)/(a*Vt))-((V+Io*Rs)/Rp1)
or
I=Ipv-Io*exp((V+Ic*Rs)/(a*Vt))-((V+Ic*Rs)/Rp1)
Where Ic may be a collector current that requires additional equations prior attempting to solve I and then plot.
.
So omitting I in plot or correcting the I equation you should be able to plot.
.
Yet, for further assistance, would it be possible for you to show the circuit diagram?
is it a transistor bias that you are modelling? or a diode?
if you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG

6 commentaires

Emircan Han
Emircan Han le 30 Juin 2017
Hello John, i sent e-mail to your adress for details. Can you check please.
Thanks for your answer
John BG
John BG le 30 Juin 2017
Modifié(e) : John BG le 1 Juil 2017
Hi Emircan
Got it, have a look, I have implemented the equations and the result matches the expected amount:
clear all;close all;
Imp=7.61;Isc=8.21;
Vmp=26.3;Voc=32.9;
Pmaxe=200.143;
kv=-.123;ki=.0032;ns=54;
a=1.3
Rs=0;G=1e3;Gn=1e3;
tol=0.1 % abs(Pmax-Pmaxe)<tol
dRs=.01
q=1.602e-19;Tnom=298;K=1.38e-23;T=299;
dt=T-Tnom; % T-Tnom=1
Vt=K*Tnom*ns/q
I0= (Isc+ki*dt)/exp((Voc+kv*dt)/(a*Vt)) % eq.7
Rpmin=Vmp/(Isc-Imp)-(Voc-Vmp)/Imp % eq.11
% Pmax=I0^2/Rpmin % Watts
Pmax=Isc^2/Rpmin;
err=abs(Pmax-Pmaxe);
Rp=Rpmin;
Rs_reg=0;
iter=0;
while err>tol
iter=iter+11;
Rs=Rs+dRs
Rs_reg=[Rs_reg Rs];
Ipv=(Rp+Rs)/Rp*Isc; % eq.10
Ipv=(Ipv+ki*dt)*G/Gn; % eq.4
Rp=Vmp*(Vmp+Imp*Rs)/(Vmp*Ipv-Vmp*I0*exp((Vmp+Imp*Rs)/(ns*a)*(q/(K*T)))+Vmp*I0-Pmaxe) % eq.9
ins_reg=[];
for s=0:.3:33
f1=@(v,in,Ipv_,I0_,Rs_,Vt_,a_,Rp_) in-Ipv_+I0_*(exp((v+Rs_*in)/(Vt_*a_))-1)+1/Rp_*(v+Rs_*in);
Ipv_=Ipv;I0_=I0;Rs_=Rs;Vt_=Vt;a_=a;Rp_=Rp; v=s;
f2=@(in) f1(v,in,Ipv_,I0_,Rs_,Vt_,a_,Rp_);
ins=fzero(f2,.1);
ins_reg=[ins_reg;ins];
end
% I=max(ins_reg) % test
% Pmax=I^2/Rp % Watts
% yyaxis left;plot(ins_reg);grid on; % plot current
% hold all;
% yyaxis left;plot([0:.3:33]); % plot voltage sweep
p=[0:.3:33].*ins_reg';
% yyaxis right;plot(p)
Pmax=max(p)
err=abs(Pmax-Pmaxe)
end
Resulting
Pmax
= 200.2033 W
taking 132 iterations
iter
= 132
with 0.12Ohm, substrate resistance?
Rs
= 0.1200
Comment: the % plot lines
I=max(ins_reg) % test
Pmax=I^2/Rp % Watts
yyaxis left;plot(ins_reg);grid on; % plot current
hold all;
yyaxis left;plot([0:.3:33]); % plot voltage sweep
p=[0:.3:33].*ins_reg';
yyaxis right;plot(p)
are used to obtain this graph
But only used the test plot on 1st round to see whether values on the right track.
If you find this answer useful would you please be so kind to consider marking my answer as Accepted Answer?
To any other reader, if you find this answer useful please consider clicking on the thumbs-up vote link
thanks in advance
John BG
Emircan Han
Emircan Han le 4 Juil 2017
Hello John,
Thank you very very much. I'm looking your codes and i was working on it since you sent and sorry just i could write you for thanks. It is really useful.
Emircan Han
Emircan Han le 4 Juil 2017
and also one question, how can i see different values of Rp for Rs on graph.
for example, If just I need to see Rs=0 Rs=1 Rs=2 Rs=2.21 lines on graph, is it possible? and how can i see Rp values for these points?
Tabich Ouijdane
Tabich Ouijdane le 18 Juin 2018
Hi John,
Please can you tell me if you used an external function f1 and f2? I did'nt really understand the for loop.
Thanks in advance for your answer!
nour gaber
nour gaber le 6 Déc 2022
where the paper for this code

Connectez-vous pour commenter.

Plus de réponses (3)

Walter Roberson
Walter Roberson le 30 Juin 2017

2 votes

syms Vt Rp Rpmin Io Ipv V I Rp1 Pmax P Rs
So I starts as a symbolic variable.
I=Ipv-Io*exp((V+I*Rs)/(a*Vt))-((V+I*Rs)/Rp1)
When rs is 0 then all occurrences of the symbolic variable I are multiplied by 0 so the symbolic variable drops out of the equation. When rs is not 0 then the symbolic variable I stays in the equation giving a result that involves the symbolic variable I. Confusingly the result is then written to I.
When I is then used in the plot() it involves the symbolic variable I. That cannot be be plotted.
Question: why are you creating so many variables as symbolic and then overwriting them with numeric values? That confuses you and confuses us.

1 commentaire

Emircan Han
Emircan Han le 30 Juin 2017
Modifié(e) : Walter Roberson le 30 Juin 2017
Hello Walter, thanks for answering.
Actually if i put out Rs from symbolic values still it's not working. I see when Rs=0, I is dropping out. But when I put value for Rs also i need that I-V curve. So i know matlab lets me to do that but, how? where is problem?
or is there any other for my equations because thing is;
V has to be between "0 <= V <= 32.9"
and first i should see I-V curve for
"I=I=Ipv-Io*exp((V+I*Rs)/(a*Vt))-((V+I*Rs)/Rp1)"
then i should change Rs value
and i should check how that curve is changing.
also i need P-V curve for P=IxV equation. (I get it but Rs value is also problem for it)

Connectez-vous pour commenter.

Wissal EL FADIL
Wissal EL FADIL le 3 Juil 2017

1 vote

I think you should solve the output current equation using the Newton Raphson method and then you can proceed with the code. I am acctually working on the same thing and I am still struggling to find the solution of the current equation.

2 commentaires

Emircan Han
Emircan Han le 4 Juil 2017
Hello Wissal,
John's codes are useful to see parameter values with good initial points. I could't find good Newton Raphson codes for PV equations but if you find some can you please share with me?
Zia
Zia le 6 Juin 2024
dear Wisaal . have you find the solution for this? i mean NRM..? i am working on the same topic, lets get connected .plz

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by