The distance traveled by a ball falling in the air is given by the equation x = x_{0} + v_{0}*t + 1/2 * a * t ^ 2
18 次查看(过去 30 天)
显示 更早的评论
The distance traveled by a ball falling in the air is given by the equation x = x_{0} + v_{0}*t + 1/2 * a * t ^ 2 Use MATLAB to calculate the position of the ball at time t = 5s x_{0} = 10m v_{0} = 15m / s and a = - 9.81m / (s ^ 2)
6 个评论
Dyuman Joshi
2024-2-21
编辑:Dyuman Joshi
2024-2-21
You have calculated the displacement of the ball, but the question asks for position.
Now, how will you calculate position from the given value?
Torsten
2024-2-21
Use MATLAB to calculate the position of the ball at time t = 5s x_{0} = 10m v_{0} = 15m / s and a = - 9.81m / (s ^ 2)
Just put the values in the equation.
x = 10 + 15*5 + 1/2 * (-9.81) * 5^2
Thus the ball made a big hole in the ground.
回答(2 个)
Sam Chak
2024-2-21
Hi @Felix Jim
It might be beneficial for you to explore how to utilize MATLAB for solving dynamical equations, particularly when dealing with systems where the states change over time. In your case, the dynamical equation for the falling ball with neglected air resistance can be expressed through this equation:
, with m and m/s.
By performing double integration, you can obtain an analytical solution, as you described in your question.
%% Unrealistic simulation of a falling ball by naively solving the ODE in pure math's way
tspan = [0 5];
y0 = [10, 15]; % initial values y = 10 m, v = 15 m/s
[t, y] = ode45(@falling, tspan, y0);
%% Plot results
figure
plot(t, y), grid on
legend('ball''s height', 'ball''s velocity')
title('Unrealistic simulation of a falling ball'), xlabel t
%% ball's height at the end of simulation
h = y(:,1);
h(end)
%% Slightly realistic simulation of a falling ball
options = odeset('RelTol', 1e-8, 'AbsTol', 1e-10, 'Events', @touchDownEventFcn);
[t, y] = ode45(@falling, tspan, y0, options);
%% Plot results
figure
plot(t, y), grid on
legend('ball''s height', 'ball''s velocity')
title('Slightly realistic simulation of a falling ball'), xlabel t
%% the time when ball touches the surface
t(end)
%% ---- Put local functions here -----
%% Function 1: Falling motion of a non-elastic solid ball when air resistance is neglected
function dydt = falling(t, y)
a = -9.81; % gravity
dydt(1,1) = y(2); %
dydt(2,1) = a;
end
%% Function 2: Stop simulation when the ball has touched the hard surface without deformation or bouncing
function [position, isterminal, direction] = touchDownEventFcn(t, y)
position = y(1); % The state variable that we want to be zero
isterminal = 1; % Halt integration
direction = -1; % The zero can be approached when x1 is decreasing
end
1 个评论
Sam Chak
2024-2-21
@Felix Jim, you can also use MATLAB to solve this equation
to determine the time when the ball hits the ground.
help fzero
VBBV
2024-2-21
Here is another simple way to find the position
t = 0:0.01:10; % consider a time vector for ball displacement (say 10s)
x0 = 10;
v0 = 15;
a = -9.81; % acceleration
x = x0+v0*t+0.5*a*t.^2;
hold on
plot(t,x); ylim([-50 50])
idx = t == 5; % find the index of 5s in time vector
plot(t(idx),x(idx),'r+','MarkerSize',20,'Linewidth',2); xlabel('time [s]');ylabel('position'); grid
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!