Matlab 曲线动态绘制

Matlab 复制代码
axes(handles.axes1); % 选定所画坐标轴 figure也可
h1 = animatedline;
h1.Color = 'b';
h1.LineWidth = 2;
h1.LineStyle = '-'; % 线属性设置
for i = 1 : length(x)
    addpoints(h1,x(i),y(i)); % x/y为待绘制曲线数据
    drawnow;
    pause(0.01); % 画点间停顿
end

示例:

Matlab 复制代码
figure; % 选定所画坐标轴 figure也可
x = 1:10;
y = rand(1 , 10) * 10;
h1 = animatedline;
h1.Color = 'b';
h1.LineWidth = 2;
h1.LineStyle = '-'; % 线属性设置
% pic_num = 1;
for i = 1 : length(x)
    addpoints(h1,x(i),y(i)); % x/y为待绘制曲线数据
    drawnow;
    pause(0.1); % 画点间停顿
    % F = getframe(gcf);
    % I = frame2im(F);
    % [I,map]=rgb2ind(I,256);
    % if pic_num == 1
    %     imwrite(I,map,'test.gif','gif','Loopcount',inf,'DelayTime',0.2);
    % else
    %    imwrite(I,map,'test.gif','gif','WriteMode','append','DelayTime',0.2);
    % end
    % pic_num = pic_num + 1;
end

如果需要更好的显示可以提前设置好xlim/ylim(注释掉的地方是Matlab GIF生成代码)

相关推荐
恋猫de小郭3 分钟前
Flutter 3.50.0 Release 的第一个崩溃,修好了,还没 hotfix
android·前端·flutter
吃我一窝jio11 小时前
Python与Go线程模型深度对比
java·开发语言·python
eggwyw11 小时前
C++ union 的一种妙用法
开发语言·c++
starzy199013 小时前
深入理解Scala隐式函数:自动类型转换
开发语言·后端·scala
IT_陈寒14 小时前
Redis那个过期删除策略,差点让我线上崩了
前端·人工智能·后端
jianqiang.xue14 小时前
Espressif-IDE进入维护模式:乐鑫把ESP32开发的宝押给VS Code
前端·css·ide
特创数字科技15 小时前
纯本地离线运行的文档脱敏工具(技术分享)
前端·驱动开发·python
心之语歌15 小时前
uni-app uts原生插件开发:uts 与 Kotlin 交互踩坑实录(附解决方案)
前端·后端
再吃一根胡萝卜15 小时前
DSH 插件数据链路:Host 管数据,Client 只管画
前端
feixing_fx15 小时前
CSS 变量(Custom Properties):构建可扩展的主题切换系统
前端·css·前端框架·html·css3