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

15 vues (au cours des 30 derniers jours)
Jin
Jin le 11 Avr 2023
Commenté : Amit Dhakite le 11 Avr 2023
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.

Réponses (1)

Amit Dhakite
Amit Dhakite le 11 Avr 2023
Modifié(e) : Amit Dhakite le 11 Avr 2023
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 commentaires
Jin
Jin le 11 Avr 2023
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 le 11 Avr 2023
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:

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB 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!

Translated by