- Convert the x and y ‘sym’ vectors into double vector
Frame increase in comet function
4 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Gregorio Garza Treviño
le 23 Mar 2023
Modifié(e) : Gregorio Garza Treviño
le 27 Mar 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)))
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 commentaires
Réponse acceptée
Sachin
le 23 Mar 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:
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 commentaire
Plus de réponses (1)
Jack
le 23 Mar 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.
0 commentaires
Voir également
Catégories
En savoir plus sur Surface and Mesh Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!