
그래프를 따라 움직이는 또 다른 그래프
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
sin 함수를 따라 움직이는 원을 제가 임의로 설정하고 싶은데 어떻게하면 되는지 궁금합니다
임의의 원의 중심이 sin함수를 따라 움직이는것을 표현하고 싶습니다.
0 Kommentare
Antworten (1)
Angelo Yeo
am 26 Dez. 2023
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
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!