How to fix legend error??
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Star Strider
2021-4-30
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
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!