如何用matlab将​一组数据绘制成动态曲​线,下面代码是绘制动​态圆函数曲线,如何用​数据代替?附件是想要​的效果。

13 visualizaciones (últimos 30 días)
华纳娱乐开户电话【微8785092】
%% 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图片

Respuesta aceptada

华纳娱乐开户【微8785092】
华纳娱乐开户【微8785092】 el 20 de Mayo de 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

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!