如何用matlab将一组数据绘制成动态曲线,下面代码是绘制动态圆函数曲线,如何用数据代替?附件是想要的效果。
13 views (last 30 days)
Show older comments
华纳娱乐开户电话【微8785092】
on 20 May 2023
Answered: 华纳娱乐开户【微8785092】
on 20 May 2023
%% 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图片
0 Comments
Accepted Answer
华纳娱乐开户【微8785092】
on 20 May 2023
做一个示例程序:
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
0 Comments
More Answers (0)
See Also
Categories
Find more on Resizing and Reshaping Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!