How to remove asymptote lines from my plots?
25 views (last 30 days)
Show older comments
My plots are generating asymptote lines. Here is the code:
syms x y
r=pi;
k=r.^(1/4);
h = 1.054*10^(-34); %value of hbar
omega=.5.*pi;
psi =0; %initialise psi
N=1; %mean value
j=2;
h2 = figure;
filename = 'CoherentSHO.gif';
for t=1:1:j
psi =0;
for n=0:1:10
c = abs(sqrt(N^n*exp(-N)/factorial(n)));
En=h.*omega.*(n+1/2);
un=(hermiteH(n,x)/(k*sqrt(2*factorial(n)))*exp(-x^{2}/2)).*exp(-1i.*En.*t./h);
psi = psi + c.*un;
end
%u=(psi.*conj(psi));
subplot(j,1,t)
h4=fplot(psi.*conj(psi));
drawnow()
h4.NodeChildren(1).Visible='on';
axis([-6 6 0 1])
ylabel('|\psi_n(x,t)|^2', Rotation=0)
title(sprintf('t=%0.1f', t));
% Capture the plot as an image
frame = getframe(h2);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,1024);
% Write to the GIF File
if t == 0
imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
else
imwrite(imind,cm,filename,'gif','WriteMode','append');
end
end
1 Comment
Walter Roberson
on 29 Oct 2021
easiest way: don't use fplot. subs() specific values into the expression, double(), plot the result
Accepted Answer
Star Strider
on 29 Oct 2021
This is actually fairly straightforward using the ShowPoles property —
syms x
y = tan(x);
figure
fplot(tan(x), [-pi pi])
title('Original')
figure
hfp = fplot(tan(x), [-pi pi]);
hfp.ShowPoles = 'off';
title('Showpoles ''off''')
Expertiment with other properties for different results.
.
0 Comments
More Answers (0)
See Also
Categories
Find more on Numbers and Precision in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
