Hi
my code is running well but I have a legend error
when I write 'legend('Curve Name')' it appears only the first one
(Warning: Ignoring extra legend entries.
> In legend>set_children_and_strings (line 646)
In legend>make_legend (line 316)
In legend (line 259)
In finalstepsolar (line 68)
Warning: Ignoring extra legend entries.
> In legend>set_children_and_strings (line 646)
In legend>make_legend (line 316)
In legend (line 259)
In finalstepsolar (line 82)
>> )
any help please
K=1.38065e-23; %Boltzman Constant
q=1.602e-19; %Electron's Charge
Iscn=3.8; %Desigerable Short Circuit Current
Vocn=21.1; % Desigerable Open Circuit Voltage
Kv=-0.073; % Temperature Voltage Constant
Ki=0.003; %Temperature Current Constant
Ns=36; %Number of Series Conected Cells
Np=6;
T=25+273; % Operating Temperature in Kelvin
Tn=30+273; %Temperature at STC
Gn=1000; %Irradiance at STC
A=3.3; %Diode Ideality Constant
%%A= [Si-mono=1.2, Si- poly =1.3, a-Si:Hi=1.8,a-Si:Hitandem=3.3,a-Si:Hitriple=5, CdTe=1.5, CIS=1.5, AsGa=1.3 ]
a=(Ns*A*K*Tn)/q;
Eg=1.2; %Band Gap of silicon at Temperature of STC condition [ 25 deg. Cel]
G=1000; %Actual Irradiance
Rs=0.221; %Series Resistance of Equivalent PV cell
Rp=415.405; %Parallel Resistance of Equivalent PV cell
%%%%%%%%%%%%%%% Parameter's Value Calculation %%%%%%%%%%%%%%%%%
Tn2=80+273;
for Tni=Tn:5:Tn2
Vtn=Ns*((K*Tn)/q); % Equation 2
I0n=Iscn/((exp(Vocn/(a*Vtn)))-1); % Equation 5
I0=I0n*((Tni/T)^3)*exp(((q*Eg/(a*K))*((1/Tni)-(1/T)))); %Equation 4
Ipvn=Iscn;
Ipv=(G/Gn)*(Ipvn+Ki*(T-Tni)); %Equation 3
Vt=Ns*((K*T)/q);
i=1;
I(1)=0;
for (V=Vocn: -0.1:0)
I_term1=I0*(exp((V+I(i)*Rs)/(Vt*a))-1)*Np; %Part of Equation 1
I_term2= (V+I(i)*Rs)/Rp; % Part of Equation 1
I(i+1)=Ipv-(I_term1+I_term2); %Equation 1
%%%%Ipv(i)=(G/Gn)*(Ipvn+Ki*(T-Tni));
if I(i)>0 % Negative Power and Current Control Loop
I(i)=I(i);
else
I(i)=0;
end
Pi(i)=V*I(i);
Vi(i)=V;
i=i+1;
end
%%%%%%%%%%%% Graphical Interface %%%%%%%%%%%%%%%%%%%
figure
hold on;
plot(Vi(1:i-1),I(1:i-1),'b', 'Linewidth',1.5)
xlabel('Voltage (volt)');
ylabel('Current (Amp)');
legend('T=30 C','T=35 C','T=40 C','T=45 C','T=50 C','T=55 C','T=60 C','T=65 C','T=70 C','T=75 C','T=80 C')
idxmax = find(Pi == max(Pi));
figure
plot(Vi(1:i-1),Pi(1:i-1), '-p','MarkerIndices',[ idxmax],...
'MarkerFaceColor','red',...
'MarkerSize',8)
xlabel('Voltage (volt)');
ylabel('Power (Watt)');
legend('T=30 C','T=35 C','T=40 C','T=45 C','T=50 C','T=55 C','T=60 C','T=65 C','T=70 C','T=75 C','T=80 C')
end

4 commentaires

Jonas
Jonas le 29 Avr 2021
if you plot in a loop and you want all plots to be to be in the same figure then please call figure() once before the loop and the legend() command once after the loop
Jan
Jan le 29 Avr 2021
Modifié(e) : Jan le 29 Avr 2021
Avoid confusing useless expressions like: I(i)=I(i); This wastes time only.w
if I(i)>0 % Negative Power and Current Control Loop
I(i)=I(i);
else
I(i)=0;
end
% Nicer:
I(i) = max(0, I(i)); % [EDITED, Thanks Raymond]
Raymond Norris
Raymond Norris le 29 Avr 2021
max, not min, right?
zina shadidi
zina shadidi le 30 Avr 2021
Thanks alot Jan and thank you Raymond. It is very nice of you to Replay
But my probem still exist.

Connectez-vous pour commenter.

 Réponse acceptée

Star Strider
Star Strider le 30 Avr 2021

0 votes

Try this —
K=1.38065e-23; %Boltzman Constant
q=1.602e-19; %Electron's Charge
Iscn=3.8; %Desigerable Short Circuit Current
Vocn=21.1; % Desigerable Open Circuit Voltage
Kv=-0.073; % Temperature Voltage Constant
Ki=0.003; %Temperature Current Constant
Ns=36; %Number of Series Conected Cells
Np=6;
T=25+273; % Operating Temperature in Kelvin
Tn=30+273; %Temperature at STC
Gn=1000; %Irradiance at STC
A=3.3; %Diode Ideality Constant
%%A= [Si-mono=1.2, Si- poly =1.3, a-Si:Hi=1.8,a-Si:Hitandem=3.3,a-Si:Hitriple=5, CdTe=1.5, CIS=1.5, AsGa=1.3 ]
a=(Ns*A*K*Tn)/q;
Eg=1.2; %Band Gap of silicon at Temperature of STC condition [ 25 deg. Cel]
G=1000; %Actual Irradiance
Rs=0.221; %Series Resistance of Equivalent PV cell
Rp=415.405; %Parallel Resistance of Equivalent PV cell
%%%%%%%%%%%%%%% Parameter's Value Calculation %%%%%%%%%%%%%%%%%
Tn2=80+273;
Dname1 = {'T=30 C','T=35 C','T=40 C','T=45 C','T=50 C','T=55 C','T=60 C','T=65 C','T=70 C','T=75 C','T=80 C'};
figure
hold on
k1 = 0;
for Tni=Tn:5:Tn2
k1 = k1+1;
Vtn=Ns*((K*Tn)/q); % Equation 2
I0n=Iscn/((exp(Vocn/(a*Vtn)))-1); % Equation 5
I0=I0n*((Tni/T)^3)*exp(((q*Eg/(a*K))*((1/Tni)-(1/T)))); %Equation 4
Ipvn=Iscn;
Ipv=(G/Gn)*(Ipvn+Ki*(T-Tni)); %Equation 3
Vt=Ns*((K*T)/q);
i=1;
I(1)=0;
for (V=Vocn: -0.1:0)
I_term1=I0*(exp((V+I(i)*Rs)/(Vt*a))-1)*Np; %Part of Equation 1
I_term2= (V+I(i)*Rs)/Rp; % Part of Equation 1
I(i+1)=Ipv-(I_term1+I_term2); %Equation 1
%%%%Ipv(i)=(G/Gn)*(Ipvn+Ki*(T-Tni));
if I(i)>0 % Negative Power and Current Control Loop
I(i)=I(i);
else
I(i)=0;
end
Pi(i)=V*I(i);
Vi(i)=V;
i=i+1;
end
%%%%%%%%%%%% Graphical Interface %%%%%%%%%%%%%%%%%%%
% figure
subplot(2,2,1)
hold on
plot(Vi(1:i-1),I(1:i-1),'b', 'Linewidth',1.5, 'DisplayName',Dname1{k1})
xlabel('Voltage (volt)');
ylabel('Current (Amp)');
% legend('T=30 C','T=35 C','T=40 C','T=45 C','T=50 C','T=55 C','T=60 C','T=65 C','T=70 C','T=75 C','T=80 C')
idxmax = find(Pi == max(Pi));
% figure
subplot(2,2,2)
hold on
plot(Vi(1:i-1),Pi(1:i-1), '-p','MarkerIndices',[ idxmax],...
'MarkerFaceColor','red',...
'MarkerSize',8, 'DisplayName',Dname1{k1})
xlabel('Voltage (volt)');
ylabel('Power (Watt)');
hl = legend;
end
hold off
subplot(2,2,[3 4])
Ax = gca;
Ax.Visible = 'off';
pos = Ax.Position
pos = 1×4
0.1300 0.1100 0.7750 0.3412
hl.NumColumns = 3;
hl.Position = pos;
I added the ‘k1’ counter and changed the order of the figure and hold calls, and changed the legend call to include 'DisplayName' strings.
This should get you closer to the result you want.

2 commentaires

zina shadidi
zina shadidi le 1 Mai 2021
thank you Star Strider , its working and I like the new figure.
Star Strider
Star Strider le 1 Mai 2021
As always, my pleasure!
Thank you!

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Version

R2018b

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by