How plot graph with loop over existing graph on new figure

3 views (last 30 days)
clc;
clear all;
K = 1.38065*10^-23; %Boltzmann constant
q = 1.602 *10^-19; %charge of electron
Iscn = 8.21; %Nominal SC current
Vocn = 34.9; %Nominal OC voltage
Kv = -0.123; %Temperature voltage constant
Ki = 0.0032; %Temperature current constant
Ns = 54; %no. of series connected cells
T = 25+273; %operating 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 Celsius
G = 1000; %Actual Irradiance
Rs = 0.221; Rp = 415.405;
for n=0:5
G = G+100;
Vth = Ns*(K*Tn/q);
Ion = Iscn/((exp(Vocn/(a*Vth)))-1);
Io = Ion*((Tn/T)^3)*exp(((q*Eg/(a*K))*((1/Tn)-(1/T))));
Ipvn = Iscn;
Ipv = (Ipvn + Ki*(T-Tn))*(G/Gn);
Vt = Ns*(K*T/q);
I = zeros (330,1); i = 1; I(1,1)=0;
for V=0:0.1:34.9
I_part = Io*(exp((V+(I(i,1)*Rs))/(Vt*a))-1) + ((V+(Rs*I(i,1)))/Rp);
I(i+1) = Ipv - I_part;
V1(i)=V;
P(i)= V*I(i);
i=i+1;
end V1(i)=V1(i-1);
P(i) = P(i-1);
V1=transpose(V1);
hold on xlabel('output voltage'); ylabel('output power');
plot(V1,P,"linewidth",3);
end
hold off
  4 Comments

Sign in to comment.

Answers (1)

KALYAN ACHARJYA
KALYAN ACHARJYA on 8 May 2020
Edited: KALYAN ACHARJYA on 8 May 2020
K = 1.38065*10^-23; %Boltzmann constant
q = 1.602 *10^-19; %charge of electron
Iscn = 8.21; %Nominal SC current
Vocn = 34.9; %Nominal OC voltage
Kv = -0.123; %Temperature voltage constant
Ki = 0.0032; %Temperature current constant
Ns = 54; %no. of series connected cells
T = 25+273; %operating 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 Celsius
Gvalue =1000; %Actual Irradiance
Rs = 0.221;
Rp = 415.405;
G=0;
for n=0:4
G = G +100;
Vth = Ns*(K*Tn/q);
Ion = Iscn/((exp(Vocn/(a*Vth)))-1);
Io = Ion*((Tn/T)^3)*exp(((q*Eg/(a*K))*((1/Tn)-(1/T))));
Ipvn = Iscn;
Ipv = (Ipvn + Ki*(T-Tn))*(G/Gn);
Vt = Ns*(K*T/q);
I = zeros (330,1); i = 1; I(1,1)=0;
for V=0:0.1:34.9
I_part = Io*(exp((V+(I(i,1)*Rs))/(Vt*a))-1) + ((V+(Rs*I(i,1)))/Rp);
I(i+1) = Ipv - I_part;
V1(i)=V; P(i)= V*I(i); i=i+1;
end
V1(i)=V1(i-1);
P(i) = P(i-1);
V1=transpose(V1);
xlabel('output voltage');
ylabel('output power');
plot(V1,P,'linewidth',3);
hold on
grid on;
end
If you are looking for different figure, then
K = 1.38065*10^-23; %Boltzmann constant
q = 1.602 *10^-19; %charge of electron
Iscn = 8.21; %Nominal SC current
Vocn = 34.9; %Nominal OC voltage
Kv = -0.123; %Temperature voltage constant
Ki = 0.0032; %Temperature current constant
Ns = 54; %no. of series connected cells
T = 25+273; %operating 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 Celsius
Gvalue =1000; %Actual Irradiance
Rs = 0.221;
Rp = 415.405;
G=0;
for n=0:4
G = G +100;
Vth = Ns*(K*Tn/q);
Ion = Iscn/((exp(Vocn/(a*Vth)))-1);
Io = Ion*((Tn/T)^3)*exp(((q*Eg/(a*K))*((1/Tn)-(1/T))));
Ipvn = Iscn;
Ipv = (Ipvn + Ki*(T-Tn))*(G/Gn);
Vt = Ns*(K*T/q);
I = zeros (330,1); i = 1; I(1,1)=0;
for V=0:0.1:34.9
I_part = Io*(exp((V+(I(i,1)*Rs))/(Vt*a))-1) + ((V+(Rs*I(i,1)))/Rp);
I(i+1) = Ipv - I_part;
V1(i)=V; P(i)= V*I(i); i=i+1;
end
V1(i)=V1(i-1);
P(i) = P(i-1);
V1=transpose(V1);
figure, plot(V1,P,'linewidth',3);
grid on;
xlabel('output voltage');
ylabel('output power');
end
  5 Comments
Vinay Sharma
Vinay Sharma on 8 May 2020
Edited: Vinay Sharma on 8 May 2020

Thank you sir , My problem is solved I used "hold on" after the "plot" then i use saveas command to save each plot

H=figure()

For ....

....

Plot(...)

Hold on

Saveas(h,sprintf("fig%d.png",n));

End

Ridzuan Rashid
Ridzuan Rashid on 27 Dec 2023
hi can i ask question. why i have error using plot must be same lenght if i change the value Vocn. please someone help me.thankyou
clc;
clear all;
K = 1.38065e-23; %Boltman Constants
q = 1.602e-19; %charge of electron
Iscn = 1.80; %Nominal SC current
Vocn = 21.6; %Nominal OC Voltage
Kv = -0.123; %Temperature voltage constant
Ki = 0.0032; %Temperature Current constant
Ns = 36; %n0. of serries connected cells
T = 29+273; %operating temperature
Tn = 25+273; %Nominal temperature
Gn = 1000; %Nominal irrandiace
a = 1.3; %diode ideality constant
Eg = 1.12; %ban gap of silicon at 25 degree celcius
G = 1000; %actual irradiation
Rs = 0.221;
Rp = 415.405;
Vtn = Ns*(K*Tn/q);
Ion = Iscn/ ((exp(Vocn/(a*Vtn)))-1)
Io = Ion*((Tn/T)^3)*exp(((q*Eg/(a*K))*((1/Tn)-(1/T))));
Ipvn = Iscn;
Ipv = (Ipvn + Ki*(T-Tn))*(G/Gn)
Vt = Ns*(K*T/q);
I = zeros(330,1);
i=1;
I(1,1)=0;
for V=21.6:-0.1:0
I_part = Io*(exp((V+(I(i,1)*Rs))/(Vt*a))-1) + ((V+(Rs*I(i,1)))/Rp);
I(i+1) = Ipv - I_part;
V1(i)=V;
P(i)=V*I(i);
i=i+1;
end
V1(i)=V1(i-1);
P(i) = P(i-1);
V1=transpose(V1);
% subplot(3,1,1)
plot(V1,I);
%subplot(3,1,2)
xlabel("Voltage")
ylabel("Current")
%plot(V1,P);
%subplot(3,1,3)
%plot (V1,I_part);

Sign in to comment.

Categories

Find more on MATLAB in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!