Frame increase in comet function

4 visualizaciones (últimos 30 días)
Gregorio Garza Treviño
Gregorio Garza Treviño el 23 de Mzo. de 2023
Editada: Gregorio Garza Treviño el 27 de Mzo. de 2023
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)))
v_1_segundo = 10.0499
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_1_segundo = 20.0040
a_relativa = subs((diff(r,t,2)),t,1)
a_relativa = 
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)

Respuesta aceptada

Sachin
Sachin el 23 de Mzo. de 2023
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:
  1. Convert the x and y ‘sym’ vectors into double vector
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 comentario
Gregorio Garza Treviño
Gregorio Garza Treviño el 27 de Mzo. de 2023
Editada: Gregorio Garza Treviño el 27 de Mzo. de 2023
Although it wasnt the solution to my problem, turns out that you were correct in the fact that it had used all my x and y values. The solution was to lower the amount of values I had on my array by just increasing the size of the separation of each value in my original t array, therefore generating less elements but still having the same overall path described by my theta and radius function

Iniciar sesión para comentar.

Más respuestas (1)

Jack
Jack el 23 de Mzo. de 2023
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.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by