How to remove asymptote lines from my plots?

25 次查看(过去 30 天)
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 个评论
Walter Roberson
Walter Roberson 2021-10-29
easiest way: don't use fplot. subs() specific values into the expression, double(), plot the result

请先登录,再进行评论。

采纳的回答

Star Strider
Star Strider 2021-10-29
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 个)

类别

Help CenterFile Exchange 中查找有关 Numbers and Precision 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by