Draw curves in matlab

2 次查看(过去 30 天)
Nadia jabeen
Nadia jabeen 2021-5-4
评论: KSSV 2021-5-4
I have multiple excel files.From which I want to make curves for theoratical and experimental part. I have written code in which I have made curve by import txt file and this graph contains one theoratical and one experimental curve at T=1500. But now I want to draw multiple theoratical and experimental curves from different excel files or sheets in which value of T will be change for each file. Can anayone help me to write code? I have attached matlab code.
syms x
load Book1.txt;
wave=Book1(:,1);
corr=Book1(:,2);
Efficiency=Book1(:,3);
experiment=Book1(:,4);
theoratical=Book1(:,5);
% Theoratical curve
counts=(experiment/corr);
Photoelectrons=((counts-50)*4)/5;
Photons=((Photoelectrons)*(Efficiency));
Energy =(Photons*(1240/wave));%(nm)
W=(Energy/100);
N=(W/(5.3*10^(-12)));
yyaxis left
plot(wave,N)
hold on
% experimental curve
t=100;
h=6.62e-34;%J*s
c=3e8;%m/s
k=1.38E-23;%J/K
r=26e-6;%beam radius
T=1500;
z=5.67e-8;
f=(((15*z*T)/(3.14^4))*((k*T)/(h*c))*(x^4))*(10^6);
intf=int(f);
yyaxis right
a=fplot(intf,[600 800]);

回答(1 个)

KSSV
KSSV 2021-5-4
txtfiles = dir('*.txt') ;
N = lewngth(txtfiles) ;
for i = 1:N
load(txtfiles(i).name) ;
wave=Book1(:,1);
corr=Book1(:,2);
Efficiency=Book1(:,3);
experiment=Book1(:,4);
theoratical=Book1(:,5);
figure(i)
% Theoratical curve
counts=(experiment/corr);
Photoelectrons=((counts-50)*4)/5;
Photons=((Photoelectrons)*(Efficiency));
Energy =(Photons*(1240/wave));%(nm)
W=(Energy/100);
N=(W/(5.3*10^(-12)));
yyaxis left
plot(wave,N)
hold on
% experimental curve
t=100;
h=6.62e-34;%J*s
c=3e8;%m/s
k=1.38E-23;%J/K
r=26e-6;%beam radius
T=1500;
z=5.67e-8;
f=(((15*z*T)/(3.14^4))*((k*T)/(h*c))*(x^4))*(10^6);
intf=int(f);
yyaxis right
a=fplot(intf,[600 800]);
end
  2 个评论
Nadia jabeen
Nadia jabeen 2021-5-4
But value of T should be changed in each loop. Value of T is different for each excel file.
KSSV
KSSV 2021-5-4
Where is T present? You change it accordingle inside the loop.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Large Files and Big Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by