在matlab上有没有什么选项可以用来制作闭环系统的动画而不是图片?
我尝试使用for循环来改变阶跃响应的模拟时间,对于每个for循环交互,我尝试使用step ()函数在一秒钟内模拟一个交互,但模拟函数只显示第一次交互的结果,而绘制结果图像必须随着时间的推移绘制多个图像,以提供动画效果。
我期望看到系统的阶跃响应或斜坡响应随时间的演变。
Code that i tried to make the animation of a closed-loop transfer function
发布于 2018-12-20 16:51:15
您可以在循环中创建一系列情节,并将每个情节捕获为一帧,然后使用电影函数播放电影。
示例如下:
% capture each plot as a frame and store the frames in M
for k = 1:16
plot(fft(eye(k+16)))
axis([-1 1 -1 1])
M(k) = getframe;
end
% play recorded movie frames
figure
movie(M)这里是参考链接:https://www.mathworks.com/help/matlab/creating_plots/record-animation-for-playback.html
对于您的情况,代码可以修改如下:
j = 0;
loops = 6;
Ini = 0;
End = 1;
num = [9];
den = [1 2 9];
FT = tf(num, den);
CL = feedback(FT, 1);
figure;
while j < loops
t = Ini:0.01:End;
hold on
step(CL, 'y', t);
hold off
axis([0 10 0 1]);
j = j+1;
Ini = Ini+1;
End = End+1;
M(j) = getframe;
end
movie(M)希望能有所帮助。
https://stackoverflow.com/questions/53857638
复制相似问题