projectile motion in matlab
이전 댓글 표시
i have a question about creating a a berrier in matlab for my app.
Create an app in Matlab 2019b using App Designer. When the user selects “New”, your program should automatically create a plot with an ‘x’ symbol in a 2‐D axis where the x and y co‐ordinates of ‘x’ are both somewhere between [10,100] metres. The user must then enter an angle (in degrees) and a velocity magnitude (in m/s) representing the initial conditions of a projectile. When the user presses ‘Go’, the axis should show a line showing the trajectory of the projectile (which is originally at (x,y)=(0,1.5) metres) until the projectile hits the ground (x axis). The ‘x’ should still be visible. Assume that the projectile is exposed to earth’s gravitational force and no other forces. Your app should display a message indicating how close the projectile got to the ‘x’ position. You can award some points based on the accuracy (you can decide a fair points system). After a 3 second delay, the axis should be cleared and a new point for ‘x’ generated. The process should repeat 5 times. After the fifth projectile, the app should say ‘game over’ and display the total score of the five turns. When “New” is pressed, the score should be reset and the program should start over. Be sure to disable and enable the ‘Go’ button when appropriate.
For HD – Add a vertical barrier somewhere on the plot between the original and the ‘x’. Choose the height and positioning strategically to ensure that it is still possible to hit the ‘x’ (but it is harder). If the projectile hits the barrier, the projectile path should stop at that point. Otherwise, the program should operate in the same way.
this is my project for projectile motion we done everything and its working we're just stuck at the barrier part we're not sure how we can let the projectile stop when it hits the barrier we know how to create it but not how to let the projectile stop.
please help us understand how to do it.
regards
댓글 수: 2
darova
2020년 4월 15일
It's too much. Can you be more specific? Do you have any 'short' questions? No one is gonna do your homework for you
Abdulrahman Ghannam
2020년 4월 15일
답변 (2개)
If I understand correctly, the barrier is a vertical line defined by (x0,y0), (x0,y1) which are the bottom and top coordinates.
Assuming the projectile is traveling rightward toward the barrier, you just need to check when the following conditions occur:
P is the position of the projectile where P(1) is the x coordinate and P(2) is the y coordinate.
barrierHit = P(1) >= x(0) && P(2) >= y(0) && P(2) <= y(1);
If the projectile is travelling leftward toward the barrier, the first inequality symbol needs changed from > to <.
댓글 수: 3
Abdulrahman Ghannam
2020년 4월 15일
"the projectile is not hitting the barrier"
What does that mean? It's random path never meets the barrier? It travels through the barrier?
"we need the projectile to stop when it hit the barrier"
From my answer, when barrierHit turns to true, the stop the projectile motion. What's the problem with doing that?
Abdulrahman Ghannam
2020년 4월 16일
darova
2020년 4월 16일
See this
clc,clear
a = 60;
v = 10;
x = 0;
y = 0;
vx = v*cosd(a);
vy = v*sind(a);
g = 9.81;
dt = 0.02;
% plot([5 5],[3 5]) % wall
hold on
for i = 1:90
x = x + vx*dt;
y = y + vy*dt;
vy = vy - g*dt;
if abs(x-5) < 0.1 && (3 < y && y < 5)
vx = -0.9*vx;
x = x - 0.1;
end
plot(x,y,'ob')
pause(0.1)
end
hold off
axis equal

카테고리
도움말 센터 및 File Exchange에서 Board games에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!