Write a Matlab program (function) that can be used to model a throwing motion.

9 次查看(过去 30 天)
Task:
''The program is given the mass of the ball to be thrown, the throwing angle and the direction of the angle initial velocity. Mass = 7,26 kg distance for the throw = 20 m.''
This is where it gets tricky for me (task continues):
''The program must give the result of the range value of the throwing movement and the kinetic energy of the ball at the time of departure or drop. Air resistance does not need to be taken into account in calculations. The program must also draw a graph of the trajectory of the ball.''
I can make two separate graphs for its KE and throwing angle, but I can't solve the task at hand.
If anybody can help me to solve this, thank you a lot for your time in advance.

回答(1 个)

Amit Dhakite
Amit Dhakite 2023-4-11
编辑:Amit Dhakite 2023-4-11
Hi Sasu,
As per my understanding, you want to calculate the Kinetic Energy of the ball at the time of departure and also want to draw a graph showing the trajectory of the ball.
To calculate the Kinetic Energy of the ball, you can use the formula:
% Kinetic energy
KE = (1/2)*m*v^2;
% m = mass of the ball
% v = velocity of the ball at the time of departure
On the second part of the question on the graphical analysis, you may refer to the following MATLAB answer, which addresses a similar query:
  2 个评论
Jin
Jin 2023-4-11
Thank you for your quick reply. My code is as follows:
m = 7.26;
v0 = input('Enter initial velocity of the shot put here: ');
angle=(45);
g=9.81;
hold on
for angle = 45
tges=(2*v0.*sin(angle.*(pi/180)))/g;
t =linspace(0,tges);
vx = v0.*cos(angle.*(pi/180));
vy = v0.*sin(angle.*(pi/180));
sx = vx.*t;
sy=vy.*t-0.5*g.*t.^2;
KE=0.5*m*(v0.^2);
disp('Kinetic energy is:')
disp(KE)
plot(sx,sy);
end
hold off
It works and I sent it to my teacher but he replied:
''the code you wrote is still not a function-type program, where the numerical values ​​of all three variables would be determined as input values ​​of the program.''
Any help with this is highly appreciated since function-type is not what I'm awfully familiar with.
Amit Dhakite
Amit Dhakite 2023-4-11
I assume you are talking about the normal functions used in programming languages. In order to use function you can simply transfer the whole implementation inside a body of the function.
m = 7.26;
v0 = 10;
% OR take input from the user: input('Enter initial velocity of the shot put here: ');
angle = (45);
g = 9.81;
Kinetic_Energy = my_fun(m, v0, angle, g);
Kinetic energy is: 363
function KE = my_fun(m, v0, angle, g)
hold on
for angle = 45
tges=(2*v0.*sin(angle.*(pi/180)))/g;
t =linspace(0,tges);
vx = v0.*cos(angle.*(pi/180));
vy = v0.*sin(angle.*(pi/180));
sx = vx.*t;
sy = vy.*t-0.5*g.*t.^2;
KE = 0.5*m*(v0.^2);
disp('Kinetic energy is:')
disp(KE)
plot(sx,sy);
end
hold off
end
To know more about the function, please refer to the following link:

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by