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

조회 수: 14 (최근 30일)
Jin
Jin 2023년 4월 11일
댓글: Amit Dhakite 2023년 4월 11일
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