how to make a subplot.i did it but it has little problem.can anyone please guide me.here are codes,i combined them but didn't give the correct subplot.
1 view (last 30 days)
Show older comments
waqas muhammad
on 30 Jan 2018
Commented: waqas muhammad
on 30 Jan 2018
here is the code.
m0=0.938;R=1.2*196.97^(1/3);
t0=0.130;beta=0.375;n0=2;
x2=[0.644417475728155;0.753640776699029;0.851941747572815;0.950242718446602;1.04854368932039;1.14684466019417;1.25606796116505;1.35436893203883;1.45266990291262;1.55097087378641;1.66019417475728;1.75849514563107;1.85679611650485;1.95509708737864;2.09708737864078;2.30461165048544;2.50121359223301;2.70873786407767;2.90533980582524;3.25485436893204;3.75728155339806;4.25970873786408]
y2=[2.02167630196276;1.92179861093512;1.73660235151668;1.49172630869016;1.21807538896743;1.10069420009424;0.898776476692455;0.733899710733955;0.630413465400298;0.442180172338893;0.361064078764099;0.280262865396340;0.217543860882062;0.160518229479539;0.0967134573521131;0.0612989735304463;0.0317252106715399;0.0181703510369072;0.0104069177104193;0.00418075489660610;0.00130367268973768;0.000550940754545585]
y4pos=[2.78255940220713;2.78255940220713;2.38658978685858;2.04696827180752;1.66810053720006;1.58489319246111;1.22712523985119;1;0.857695898590894;0.630957344480193;0.488527357151939;0.359381366380463;0.278255940220713;0.204696827180752;0.129154966501488;0.0814912746902075;0.0419007910578667;0.0238658978685858;0.0135935639087853;0.00569581081073769;0.00175567629127500;0.000698947320727348]
y4neg=[2.15443469003188;2.04696827180752;1.84784979742229;1.58489319246111;1.29154966501488;1.16591440117983;1;0.774263682681127;0.664082785063485;0.464158883361278;0.359381366380463;0.292864456462524;0.226754312587080;0.166810053720006;0.105250028527773;0.0630957344480193;0.0324422607917163;0.0194486243893736;0.0110775685050971;0.00441005945417674;0.00129154966501488;0.000541169526546464]
i=0;
for pt=0.01:0.01:4.5
i=i+1;
mt=sqrt(pt^2+m0^2);
j=0;
for r=0.01:0.01:R
j=j+1;
rho=atanh(0.5*beta*(n0+2)*(r/R)^n0);
w=pt*sinh(rho)/t0;
z=mt*cosh(rho)/t0;
Q(j)=pt*mt*r*besseli(0,w)*besselk(1,z)*0.01;
end
y10(i)=sum(Q);
end
pt=[0.01:0.01:4.5];
y11=y10./sum(y10);
y12=335*y11./pt;
m0=0.938;R=1.2*196.97^(1/3);
t0=0.130;beta=0.375;n0=2;
x4=[0.644417475728155;0.753640776699029;0.851941747572815;0.950242718446602;1.04854368932039;1.14684466019417;1.25606796116505;1.35436893203883;1.45266990291262;1.55097087378641;1.66019417475728;1.75849514563107;1.85679611650485;1.95509708737864;2.09708737864078;2.30461165048544;2.50121359223301;2.70873786407767;2.90533980582524;3.25485436893204;3.75728155339806;4.25970873786408]
y4=[2.02167630196276;1.92179861093512;1.73660235151668;1.49172630869016;1.21807538896743;1.10069420009424;0.898776476692455;0.733899710733955;0.630413465400298;0.442180172338893;0.361064078764099;0.280262865396340;0.217543860882062;0.160518229479539;0.0967134573521131;0.0612989735304463;0.0317252106715399;0.0181703510369072;0.0104069177104193;0.00418075489660610;0.00130367268973768;0.000550940754545585]
y4pos=[2.78255940220713;2.78255940220713;2.38658978685858;2.04696827180752;1.66810053720006;1.58489319246111;1.22712523985119;1;0.857695898590894;0.630957344480193;0.488527357151939;0.359381366380463;0.278255940220713;0.204696827180752;0.129154966501488;0.0814912746902075;0.0419007910578667;0.0238658978685858;0.0135935639087853;0.00569581081073769;0.00175567629127500;0.000698947320727348]
y4neg=[2.15443469003188;2.04696827180752;1.84784979742229;1.58489319246111;1.29154966501488;1.16591440117983;1;0.774263682681127;0.664082785063485;0.464158883361278;0.359381366380463;0.292864456462524;0.226754312587080;0.166810053720006;0.105250028527773;0.0630957344480193;0.0324422607917163;0.0194486243893736;0.0110775685050971;0.00441005945417674;0.00129154966501488;0.000541169526546464]
i=0;
for pt=0.01:0.01:4.5
i=i+1;
mt=sqrt(pt^2+m0^2);
j=0;
for r=0.01:0.01:R
j=j+1;
rho=atanh(0.5*beta*(n0+2)*(r/R)^n0);
w=pt*sinh(rho)/t0;
z=mt*cosh(rho)/t0;
Q(j)=pt*mt*r*besseli(0,w)*besselk(1,z)*0.01;
end
y30(i)=sum(Q);
end
pt=[0.01:0.01:4.5];
y11=y30./sum(y30);
y32=335*y11./pt;
x4i=x4
y4i=interp1(pt,y32,x4i)
kafa2=y4./y4i
subplot(2,1,1)
semilogy(pt,y12,'k')
%axis([0 4.5 1e-3 1e3])
xlabel('P_{T}')
ylabel('1/2\pip_{T} d^{2}N/dp_{T}dy [c^{2}/GeV^{2}]')
semilogy(x2,y2,'r*')
subplot(2,1,2)
scatter(x4,kafa2)
xlabel('p_{T}')
ylabel('data/fit')
c2=y4pos-y4neg
d1=c2./y4i% error=
errorbar(x4,kafa2,d1,'o')
%f=c./kafa2
kafang2=((y4-kafa2)/c2).^2
S2=sum(kafang2)
%now for finding chi^2/dof.. dof in no.of exp.points-no.of free parameters.
dof=22-3 %16 is the no. of experimental points,3 is the number of free parameters
K2=S2/dof
%err=0.3*ones(size(c))
%errorbar(f,err);
%err=0.3*ones(size(c))
%errorbar(f,err);
there are two graphs i have to plot in single window which are ...
the cobination gives me a graph like this..
now the first part of theis subplot doesn't show me the fitting line as in the i have in the first individual plot...
Accepted Answer
More Answers (0)
See Also
Categories
Find more on Subplots 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!