Gif from subplot not moving
12 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi everyone, I'm trying to create a gif of subplots that are changing in value constantly, here is my code
for wt = 0:pi/8:2*pi
v=VO.*exp(-j.*beta.*z).*(1+refl.*exp(2.*j.*beta.*z)).*exp(j*wt);
i=VO.*exp(-j.*beta.*z).*(1-refl.*exp(2.*j.*beta.*z)).*(1/50).*exp(j*wt);
subplot(2,1,1);
plot(z,abs(v))
subplot(2,1,2);
plot(z,abs(i));
filename = 'saved_gif.gif';
del = 0.1; % time between animation frames
drawnow
frame = getframe(1);
im = frame2im(frame);
[imind,cm] = rgb2ind(im,256);
if wt == 0;
imwrite(imind,cm,filename,'gif','Loopcount',inf,'DelayTime',del);
else
imwrite(imind,cm,filename,'gif','WriteMode','append','DelayTime',del);
end
end
2 Commenti
Walter Roberson
il 5 Ott 2019
Unfortunately we need the values of a number of variables in order to test the code.
Risposte (1)
Walter Roberson
il 5 Ott 2019
abs(exp(j*(0:pi/8:2*pi))) are all identical to 1
abs(exp(-j*x)) is exp(imag(x)) and imag() of (0:pi/8:2*pi) is all 0, so that is all exp(0) which is identical to 1.
Your v and i values are all identical except for the exp(j*wt) term that is multiplying them all, so when you take abs() of that and the abs(exp(j*wt)) is always 1, then the abs() is the same for all of your loops. Therefore there is no movement: all of your calculations come out exactly the same.
0 Commenti
Vedere anche
Categorie
Scopri di più su Graphics Performance in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!