- Convert the x and y ‘sym’ vectors into double vector
Frame increase in comet function
조회 수: 4 (최근 30일)
이전 댓글 표시
Im trying to make an animation of a point following a set path described by 2 functions, but despite having 6.2K numbers in my x and y arrays, when I use the comet function, it only takes 11 of them leading to a very choppy animation, any way to fix this?. Here is my code, it includes some other calculations I had to do.
syms t
theta = (2/pi)*sin(pi*t);
r = 25/(t+4);
vr = diff(r,t);
vth = r*diff(theta,t);
v_1_segundo = double(sqrt(((subs(vr,t,1))^2)+((subs(vth,t,1))^2)))
ar = diff(r,t,2)-r*(diff(theta,t)^2);
ath = r*diff(theta,t,2)+2*diff(r,t)*diff(theta,t);
a_1_segundo = double(sqrt(((subs(ar,t,1))^2)+((subs(ath,t,1))^2)))
a_relativa = subs((diff(r,t,2)),t,1)
theta = theta-(pi/2);
at = 0:0.001:2*pi;
theta = subs(theta,t,at);
r = subs(r,t,at);
x = cos(theta).*r;
y = sin(theta).*r;
comet(x,y)
댓글 수: 0
채택된 답변
Sachin
2023년 3월 23일
Hi
I understand that you are having an issue with your animation values. The ‘Comet’ function is using all the values of the x and y vector.
I suggest you try these workarounds to understand the animation plot better:
x_double = double(x)
y_double = double(y)
2. Find the minimum and maximum of the converted double vectors. These values match the plots minimum and maximum values.
min(x_double)
max(x_double)
min(y_double)
max(y_double)
댓글 수: 1
추가 답변 (1개)
Jack
2023년 3월 23일
The comet function in MATLAB creates a smooth animation by connecting a small number of data points with curves. By default, it uses only a small subset of the data points to create the animation, which can result in a choppy animation if the number of data points is very large.
To increase the number of data points used by comet, you can use the comet3 function instead, which allows you to specify the x, y, and z coordinates of the data points. Since your path is two-dimensional, you can simply set the z coordinates to zero. Here's an example:
% Generate path data
at = 0:0.001:2*pi;
theta = subs(theta,t,at);
r = subs(r,t,at);
x = cos(theta).*r;
y = sin(theta).*r;
% Create animation
comet3(x, y, zeros(size(x)));
This should create a smoother animation by using more data points to interpolate the path. You can adjust the step size in the at array to control the density of the data points and the smoothness of the animation.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!