How to remove asymptote lines from my plots?

23 vues (au cours des 30 derniers jours)
Ankit Kundu
Ankit Kundu le 29 Oct 2021
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 commentaire
Walter Roberson
Walter Roberson le 29 Oct 2021
easiest way: don't use fplot. subs() specific values into the expression, double(), plot the result

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 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.
.

Plus de réponses (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by