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生成代码)

相关推荐
IT_陈寒40 分钟前
React状态更新那点事儿,我掉坑里爬了半天
前端·人工智能·后端
cwxcc44 分钟前
Google Core Web Vitals(核心网页指标)
前端·性能优化
|晴 天|1 小时前
Vue 3 + LocalStorage 实现博客游戏化系统:成就墙、每日签到、积分商城
前端·vue.js·游戏
逾明2 小时前
Claude Code及Codex的MCP安装和Mastergo MCP的使用
前端·mcp
LovroMance2 小时前
如何进行组件封装
前端
難釋懷2 小时前
Redis服务器端优化-慢查询优化
前端·redis·bootstrap
jllllyuz2 小时前
MATLAB 蒙特卡洛排队等待模拟程序
数据结构·matlab
sghuter2 小时前
Chrome如何重塑Web标准未来
前端·chrome
渣渣xiong2 小时前
从零开始:前端转型AI agent直到就业第十四天-第十七天
前端·人工智能
changshuaihua0012 小时前
React 入门
前端·javascript·react.js