フィルターのクリア

connecting sinus function with circle through animation

5 ビュー (過去 30 日間)
nirwana
nirwana 2023 年 3 月 20 日
回答済み: Cameron 2023 年 3 月 21 日
Hi...I am trying to make animation that shows sinus function is a circle as ilustrate in the fig. First my problem is how to rotate the sinus fig (i use camroll (90) but it bit weird). second how to connect the line that walk over sinus and circle?
syms t;
t=0:0.01:2*pi;
x=3*cos(t);
y=3*sin(t);
subplot(2,1,1)
plot(t,y)
subplot(2,1,2)
plot (x,y,'-b');
axis square
camroll(90)

採用された回答

Cameron
Cameron 2023 年 3 月 21 日
t=0:0.01:2*pi;
x=3*cos(t);
y=3*sin(t);
tiledlayout(2,1)
nexttile
p1 = plot(t,y);
axis square
camroll(90)
title('t vs. y')
nexttile(2)
p2 = plot(x,y,'--b');
axis square
camroll(90)
title('x vs. y')
h1 = animatedline(p1.Parent,...
'LineStyle','none',...
'Marker','o',...
'MarkerFaceColor','b',...
'MarkerEdgeColor','k');
h2 = animatedline(p2.Parent,...
'LineStyle','none',...
'Marker','o',...
'MarkerFaceColor','b',...
'MarkerEdgeColor','k');
h3 = animatedline(p2.Parent,...
'LineStyle','-',...
'Color','b',...
'Marker','none');
increment = 8;
while true %loop until you close the figure
for k = 1:increment:length(t)
addpoints(h1,t(k),y(k))
addpoints(h2,x(k),y(k))
addpoints(h3,[0,x(k)],[0,y(k)])
drawnow
clearpoints(h1)
clearpoints(h2)
clearpoints(h3)
end
for k2 = length(t):-increment:1
addpoints(h1,t(k2),y(k2))
addpoints(h2,x(k2),y(k2))
addpoints(h3,[0,x(k2)],[0,y(k2)])
drawnow
clearpoints(h1)
clearpoints(h2)
clearpoints(h3)
end
end

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatics and Dynamics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by