搜索内容 搜索用户

# [已解决] 如何用matlab将一组数据绘制成动态曲线，下面代码是绘制动态圆函数曲线，如何用数据代替？附件是想要的效果

sunmingkai 发表于 2022-5-14 22:40:22
 本帖最后由 sunmingkai 于 2022-5-14 23:18 编辑 %% 1. 动态绘制圆 T = linspace(0,2*pi,100)'; X = cos(T); Y = sin(T); figure F = MovieXY(X,Y);                 % 绘制动态曲线 Fun_F2gif(F,'Test1.gif',0.01);    % 生成gif图片

f915296eb34448d1987f78a8fd7217c5.zip

343.77 KB, 下载次数: 1

 做一个示例程序： x = linspace(0,4*pi,100); y = sin(x); h = plot(x(1),y(1)); axis([0,4*pi,-1,1]) filename = '动画示例.gif'; f = getframe(gcf); IM = f.cdata; [IM,map] = rgb2ind(IM,256); imwrite(IM,map,filename,'gif', 'Loopcount',inf,'DelayTime',0.2); for k = 2:length(x)     set(h,'XData',x(1:k),'YData',y(1:k));     drawnow     f = getframe(gcf);     IM = f.cdata;     [IM,map] = rgb2ind(IM,256);     imwrite(IM,map,filename,'gif','WriteMode','append','DelayTime',0.2);        pause(0.2); end复制代码

1 条回复

## 倒序浏览

 做一个示例程序： x = linspace(0,4*pi,100); y = sin(x); h = plot(x(1),y(1)); axis([0,4*pi,-1,1]) filename = '动画示例.gif'; f = getframe(gcf); IM = f.cdata; [IM,map] = rgb2ind(IM,256); imwrite(IM,map,filename,'gif', 'Loopcount',inf,'DelayTime',0.2); for k = 2:length(x)     set(h,'XData',x(1:k),'YData',y(1:k));     drawnow     f = getframe(gcf);     IM = f.cdata;     [IM,map] = rgb2ind(IM,256);     imwrite(IM,map,filename,'gif','WriteMode','append','DelayTime',0.2);        pause(0.2); end复制代码
 您需要登录后才可以回帖 登录 | 注册 本版积分规则 回帖后跳转到最后一页