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 Center および File ExchangeSpreadsheets についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by