How to fix legend error??
Ältere Kommentare anzeigen
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 Kommentare
Jonas
am 29 Apr. 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
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
am 29 Apr. 2021
max, not min, right?
zina shadidi
am 30 Apr. 2021
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
