그래프를 따라 움직이는 또 다른 그래프

4 次查看(过去 30 天)
jeong seop kim
jeong seop kim 2020-5-24
回答: Angelo Yeo 2023-12-26
sin 함수를 따라 움직이는 원을 제가 임의로 설정하고 싶은데 어떻게하면 되는지 궁금합니다
임의의 원의 중심이 sin함수를 따라 움직이는것을 표현하고 싶습니다.

回答(1 个)

Angelo Yeo
Angelo Yeo 2023-12-26
drawnow 함수를 이용하면 애니메이션을 그릴 수 있습니다.
아래는 sine 함수를 따라 움직이는 원에 관한 예시입니다.
n = 100;
t = linspace(-1, 1, n);
x = sin(2*pi*1*t);
close all;
fig = figure(1);
plot(t, x, 'color', lines(1))
axis([-1, 1, -1, 1])
axis square
hold on;
theta = linspace(0, 2*pi, n);
r = 0.1;
for i = 1:n
h = plot(t(i) + r * cos(theta), x(i) + r * sin(theta), 'color', lines(1));
drawnow
% exportgraphics(gca, "foo.gif", "Append", true) % gif 파일로 출력하는 경우
if i < n
delete(h)
end
end

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

Community Treasure Hunt

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

Start Hunting!