matlab - 有没有办法在matlab上绘制闭环系统的动画?
问题描述
matlab上是否有任何选项可以制作闭环系统的动画而不是图片?
我尝试使用 for 循环来改变阶跃响应的模拟时间,对于每个 for 循环交互,我尝试使用 step () 函数在一秒钟内模拟一个,但模拟函数仅显示第一次交互的结果,绘图结果图像必须随着时间的推移绘制多张图像以给人以动画的印象。
我希望看到系统的阶跃响应或斜坡响应随时间的演变。
解决方案
您可以在循环中创建一系列情节并将每个情节捕获为一帧,然后使用电影功能播放电影。
一个例子如下:
% 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)
希望能帮助到你。
推荐阅读
- python - 将韩文文本从 xml 文件提取到 csv 文件时出现编码错误
- sql - 合并三个 Big Query 表
- python - 使用 Robot 撰写关键字
- python - Django:出现错误说“在使用这种多对多关系之前需要字段“id”的值”
- python - 是否可以在 python 中导入 .fst 文件
- java - 带有 API 网关的 AWS Java Lambda 函数 - POJO 输入和 OutputStream 输出
- ios - 颤动的Firebase云消息传递未调用onResume方法
- python - 为什么 Plotly 不在 Jupyter Lab 上工作?
- kotlin - KDoc:更改参数顺序
- reactjs - 带有反应钩子的纱线博览会工作区?