필터 지우기
필터 지우기

Frame increase in comet function

조회 수: 5 (최근 30일)
Gregorio Garza Treviño
Gregorio Garza Treviño 2023년 3월 23일
편집: Gregorio Garza Treviño 2023년 3월 27일
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)

채택된 답변

Sachin
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:
  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
Gregorio Garza Treviño
Gregorio Garza Treviño 2023년 3월 27일
편집: Gregorio Garza Treviño 2023년 3월 27일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Jack
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.

카테고리

Help CenterFile Exchange에서 Animation에 대해 자세히 알아보기

태그

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by