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에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by