Gif from subplot not moving
조회 수: 12 (최근 30일)
이전 댓글 표시
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
Walter Roberson
2019년 10월 5일
Unfortunately we need the values of a number of variables in order to test the code.
답변 (1개)
Walter Roberson
2019년 10월 5일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!