Help on smoothening subplots
1 view (last 30 days)
Show older comments
Hi friends. What I am trying is to use "subplot" for my plots. However, the LINES in second subplot are not as good as in the first one, seems like the number of data points are not enough. They are not regular as in the first part. Kindly help out smoothing the lines in the second one.
x = linspace(-1, 3)';
y1=(3.004814075.*(1./1000000000000000000000)+(-1).*4.895884313.*(1./10000000000000000000000).*1i).*(-exp((-1).*1.578925694.*x)).^(2051411941./1000000000).*hypergeom(1.051411941, 3.051411940, (-1).*.5327854991.*exp((-1).*1.578925694.*x)).*(7.542374557.*10.^9.*2.^(2./3)+3.822845593.*10.^9.*2.^(1./3)+9.000000000.*10.^9).*(1.226353577.*10.^9.*2.^(2./3)+1.935206296.*10.^9.*2.^(1./3)+3.436278161.*10.^9) ;
y2= (6.689763519.*(1./10000000000000000000000)+(-1).*2.377278852.*(1./1000000000000000000000).*1i).*(-exp((-1).*1.578925694.*x)).^(482536859./200000000).*hypergeom(1.412684294, 3.412684293, (-1).*.6266138849.*exp((-1).*1.578925694.*x)).*(7.542374557.*10.^9.*2.^(2./3)+3.822845593.*10.^9.*2.^(1./3)+9.000000000.*10.^9).*(1.491698969.*10.^9.*2.^(2./3)+2.402348532.*10.^9.*2.^(1./3)+4.252509117.*10.^9);
y3=(0.3748098565e-4+(-1).*0.1286908037e-3.*1i).*(448.2866859+209.0889537.*(2.^(2./3))+312.8173642.*(2.^(1./3))).*(1.033333333+.7785283383.*(2.^(2./3))+.4502797627.*(2.^(1./3))).*(-exp((-1).*1.836486989.*x)).^2.409788254.*hypergeom(1.409788255, 3.409788253, (-1).*.3580618923.*exp((-1).*1.836486989.*x));
y4= (-0.7704312638e-2+(-1).*0.1352540393e-1.*1i).*(1.523727055.*(2.^(2./3))+1.000000000.*(2.^(1./3))+2.194753653).*(-exp((-1).*2.122148765.*x)).^(41637727./15625000).*(1.313263940+.7066097745.*(2.^(2./3))+1.000000000.*(2.^(1./3))).*hypergeom(1.664814528, 3.664814529, (-1).*.2436179959.*exp((-1).*2.122148765.*x));
subplot(2,1,1)
plot(x, [y1,y2,y3,y4], 'LineWidth', 2.0);
data_names = [{'Line 1'}, {'Line 2'}, {'Line 3'}, {'Line 4'}];
legend(data_names)
%title('Plot Examples', 'FontSize', 18);
%xlabel('\fontname{Times New Roman} Values of \eta','FontSize',22');
ylabel('\fontname{Times New Roman} \theta ^\prime(\eta)', 'fontsize', 22);
ax = gca; % current axes
ax.FontSize = 14;
set(gca,'XLim',[-0.23 1.5]);
set(gca,'YLim',[0 1]);
box off
legend;
legend('boxoff')
y5=(.6665264077+(-1).*0.4781855302e-2.*I).*hypergeom(9.002283609, 11.00228361, (-1).*2.261205697.*exp((-1).*.9144997813.*x)).*(-exp((-1).*.9144997813.*x)).^(25005709./2500000) ;
y6=(0.5314566073e-2+(-1).*0.7251467211e-2.*I).*(-exp(-(.3711793982.*(2.^(2./3))+.3992944578.*(2.^(1./3))+.4555555556).*x)).^8.298680488.*(1.460775035+.8029585698.*(2.^(2./3))+1.000000000.*(2.^(1./3))).*hypergeom(7.298680486, 9.298680487, (-1).*.5235743913.*exp(-(.3711793982.*(2.^(2./3))+.3992944578.*(2.^(1./3))+.4555555556).*x)).*(1.975707085+.9295881553.*(2.^(2./3))+1.000000000.*(2.^(1./3))) ;
y7=(8.391790784.*(1./100000000000000000000000)+2.347963772.*(1./1000000000000000000000).*I).*(-exp(-(.6007529611.*(2.^(2./3))+.4871458651.*(2.^(1./3))+.6555555555).*x)).^(7511371783./1000000000).*hypergeom(6.511371783, 8.511371781, (-1).*.1868063427.*exp(-(.6007529611.*(2.^(2./3))+.4871458651.*(2.^(1./3))+.6555555555).*x)).*(6.00752961.*10.^8.*2.^(2./3)+4.87145865.*10.^8.*2.^(1./3)+9.88888889.*10.^8).*(4.820017182.*10.^9.*2.^(2./3)+6.007698365.*10.^9.*2.^(1./3)+7.723112493.*10.^9) ;
y8=((-1).*4.486253937.*(1./100000000)+3.323872963.*(1./100000000).*I).*(3.666666667+2.482497445.*(2.^(2./3))+1.855210593.*(2.^(1./3))).*(76545.30799+49924.39961.*(2.^(2./3))+62840.63233.*(2.^(1./3))).*hypergeom(6.202971154, 8.202971153, (-1).*0.8007364224e-1.*exp((-1).*2.981601534.*x)).*(-exp((-1).*2.981601534.*x)).^7.202971157 ;
subplot(2,1,2)
plot(x, [y5, y6, y7, y8],'LineWidth', 2.0);
items_names = [{'Line 1'}, {'Line 2'}, {'Line 3'}, {'Line 4'}];
legend(items_names)
xlabel('\fontname{Times New Roman} x','FontSize',22');
ylabel('\fontname{Times New Roman} y', 'fontsize', 22);
ax = gca; % current axes
ax.FontSize = 14;
set(gca,'XLim',[0.001 1]);
set(gca,'YLim',[0 0.105]);
box off
legend;
legend('boxoff')
1 Comment
dpb
on 22 Aug 2020
...
'hypergeom' requires Symbolic Math Toolbox.
>>
so can't run here...
But, some comments on style and then an observation...
x = linspace(-1, 3)';
y1=(3.004814075.*(1./1000000000000000000000)+(-1).*4.895884313.*(1./10000000000000000000000).*1i).*(-exp((-1).*1.578925694.*x)).^(2051411941./1000000000).*hypergeom(1.051411941, 3.051411940, (-1).*.5327854991.*exp((-1).*1.578925694.*x)).*(7.542374557.*10.^9.*2.^(2./3)+3.822845593.*10.^9.*2.^(1./3)+9.000000000.*10.^9).*(1.226353577.*10.^9.*2.^(2./3)+1.935206296.*10.^9.*2.^(1./3)+3.436278161.*10.^9) ;
y2= (6.689763519.*(1./10000000000000000000000)+(-1).*2.377278852.*(1./1000000000000000000000).*1i).*(-exp((-1).*1.578925694.*x)).^(482536859./200000000).*hypergeom(1.412684294, 3.412684293, (-1).*.6266138849.*exp((-1).*1.578925694.*x)).*(7.542374557.*10.^9.*2.^(2./3)+3.822845593.*10.^9.*2.^(1./3)+9.000000000.*10.^9).*(1.491698969.*10.^9.*2.^(2./3)+2.402348532.*10.^9.*2.^(1./3)+4.252509117.*10.^9);
y3=(0.3748098565e-4+(-1).*0.1286908037e-3.*1i).*(448.2866859+209.0889537.*(2.^(2./3))+312.8173642.*(2.^(1./3))).*(1.033333333+.7785283383.*(2.^(2./3))+.4502797627.*(2.^(1./3))).*(-exp((-1).*1.836486989.*x)).^2.409788254.*hypergeom(1.409788255, 3.409788253, (-1).*.3580618923.*exp((-1).*1.836486989.*x));
y4= (-0.7704312638e-2+(-1).*0.1352540393e-1.*1i).*(1.523727055.*(2.^(2./3))+1.000000000.*(2.^(1./3))+2.194753653).*(-exp((-1).*2.122148765.*x)).^(41637727./15625000).*(1.313263940+.7066097745.*(2.^(2./3))+1.000000000.*(2.^(1./3))).*hypergeom(1.664814528, 3.664814529, (-1).*.2436179959.*exp((-1).*2.122148765.*x));
...
is very difficult to read...why not something more like
C11=complex(3.004814075,-0.4895884313)*1E-21;
C12=2.051411941;
C13=(7.542374557E9*2^(2/3)+3.822845593E9*2^(1/3)+9.000000000E9)*(1.226353577E9.*2^(2/3)+1.935206296E9*2^(1/3)+3.436278161E9);
y1=C11*-exp(-1.578925694*x)^C12.*hypergeom(1.051411941, 3.051411940,-0.5327854991*exp(-1.578925694*x))*C13;
...
Use C2n or some similar naming convention for remainder...will be much easier to read/debug.
It looks like altho I didn't dig into it thoroughly enough to make absolutely certain that the equations follow a give form--if that is the case, then writing a function or using an anonymous function that passes the coefficents could reduce the redundant code significantly further also aiding in comprehension and debugging/maintenance.
The second set are written in a variable I which is undefined in the code snippet above -- another reason to clean up the code. By symmetry, I would presume that in
y5=(.6665264077+(-1).*0.4781855302e-2.*I)....
I is intended to be the complex variable i? If so, I'd do something as was illustrated above (actually, I'd do that whatever I is really intended to be).
Finally, as to the question raised regarding the apparent lack of points/continuity on subsequent subplots -- the independent array x which is default 100 points from linspace over the range [1,3] appears to be used in both; any difference in result would thus appear to be dependent upon the form of the equations returning values in a nonlinear fashion over the range of x.
You can always up the number of points to linspace; of course, ensure the equations are actually correct as written.
Answers (0)
See Also
Categories
Find more on Logical 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!