how to use for loop with vectos?

Hello everyone. I have a simple problem (huge for me). I need to use a for loop for generating several graphs. The code will explain better--
clc
clear all
close all
%parametrs
Fs= 2.16*10^-5*pi; % Geometrical Factor for sun
Fa=pi; % Geometrical Factor for earth
q=1.6*10^-19; % Electronic Charge
h= 4.136*10^-15; % Plancks Constant
c= 3*10^8; % Speed of light
K = 8.61*10^-5; % Boltzmanns Constant
Ts=5760; % Temparature of the sun
Ta=300; % Ambient Temparature
Eg=1.6; % BandGap Energy
A=((2*Fs)/((h^3)*(c^2)));
B=((2*Fa)/((h^3)*(c^2)));
%Power Input
Irradiance=@(E) ((q*A).*(E.^3./(exp((E./(K.*Ts))-1))));
Pin=integral(Irradiance,0,inf) %gives a constant value
%Short Circuit Current
Absorbrd_Flux=@(E) ((q*A).*(E.^2./(exp((E./(K.*Ts))-1))));
Jsc=integral(Absorbrd_Flux,Eg,inf) %gives a constant value
V=1.3 %vary this value from 0:0.1:Eg i.e 0:0.1:1.6
Jd=@(E) ((q*B).*((E.^2./(exp((E-V)./(K*Ta))-1))-(E.^2./(exp(E./(K*Ta))-1))));
Jdark=integral(Jd,Eg,inf)
Jout=Jsc-Jdark
Pv=V*Jout
efficiency=Pv/Pin
%Plot Jout vs V
%Plot Pv vs V
%Plot efficiency vs V
I have checked the code manually and it works. I need to vary the value of V from 0 to 1.6 or 0 to Eg. For each value of V, need to calculate Jout, Pv, efficiency. At last, I need several xy graphs which will plot the value of V at x axis and the value of the determined variables at y axis. so actually three figures as I mentioned as comment in the code.
Someone please help me .

4 comentarios

Image Analyst
Image Analyst el 5 de Feb. de 2022
What is Jv?
@Image Analyst It was supposed to be Jout. I edited it. And also I did myself what I asked.
clc
clear all
close all
%parametrs
Fs= 2.16*10^-5*pi; % Geometrical Factor for sun
Fa=pi; % Geometrical Factor for earth
q=1.6*10^-19; % Electronic Charge
h= 4.136*10^-15; % Plancks Constant
c= 3*10^8; % Speed of light
K = 8.61*10^-5; % Boltzmanns Constant
Ts=5760; % Temparature of the sun
Ta=300; % Ambient Temparature
Eg=1.6; % BandGap Energy
A=((2*Fs)/((h^3)*(c^2)));
B=((2*Fa)/((h^3)*(c^2)));
%Power Input
Irradiance=@(E) ((q*A).*(E.^3./(exp((E./(K.*Ts))-1))));
Pin=integral(Irradiance,0,inf); %gives a constant value
%Short Circuit Current
Absorbrd_Flux=@(E) ((q*A).*(E.^2./(exp((E./(K.*Ts))-1))));
Jsc=integral(Absorbrd_Flux,Eg,inf);
V_vec = 0:0.0001:Eg;
V_num = numel(V_vec);
Current_Density = nan(1,V_num);
Power_Density = nan(1,V_num);
Efficiency = nan(1,V_num);
for m=1:V_num
V=V_vec(m);
Jd=@(E) ((q*B).*((E.^2./(exp((E-V)./(K*Ta))-1))-(E.^2./(exp(E./(K*Ta))-1))));
Jdark=integral(Jd,Eg,inf);
Jout=Jsc-Jdark;
Pv=V*Jout;
efficiency=Pv/Pin;
Current_Density(m) = Jout;
Power_Density(m) = Pv;
Efficiency(m) = efficiency;
if Jout<0
break
end
end
figure(1)
plot(V_vec,Current_Density)
figure(2)
plot(V_vec,Power_Density)
figure(3)
plot(V_vec,Efficiency)
KALYAN ACHARJYA
KALYAN ACHARJYA el 6 de Feb. de 2022
Still improvement & changes required in the code?
Md. Golam Zakaria
Md. Golam Zakaria el 6 de Feb. de 2022
nope

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Specialized Power Systems en Centro de ayuda y File Exchange.

Productos

Versión

R2018a

Preguntada:

el 5 de Feb. de 2022

Comentada:

el 6 de Feb. de 2022

Community Treasure Hunt

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

Start Hunting!

Translated by