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 Kommentare

darova
darova am 15 Apr. 2020
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
Abdulrahman Ghannam am 15 Apr. 2020
i dont neeed my homework the code is actully done, our problem is with creating the barrier. after we did our projectile is not hitting the barrier, when we create a regular game the projectile is working fine but when we put the barrier on its not working. forgive me i cannot share my code publicly as instructed by our professor.

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Adam Danz
Adam Danz am 15 Apr. 2020
Bearbeitet: Adam Danz am 15 Apr. 2020

0 Stimmen

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 Kommentare

Abdulrahman Ghannam
Abdulrahman Ghannam am 15 Apr. 2020
the x and y coordinates are genirated randomly, so we did kind of similar to what you did here but the thing is when we hit the go button the projectile is not hitting the barrier. we need the projectile to stop when it hit the barrier so that is the code that we are missing, forgive i want to share my code but as instructed by our professor we cannot share it publicly, i hope i gave you an idea about what i mean. the barrier is just a check seperate button when triggered it activates a new game with the barrier in a random location with a random size vertically. when press go its just not showing any projectile for some reason
Adam Danz
Adam Danz am 15 Apr. 2020
Bearbeitet: Adam Danz am 17 Apr. 2020
"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
Abdulrahman Ghannam am 16 Apr. 2020
Will try that thank you

Melden Sie sich an, um zu kommentieren.

darova
darova am 16 Apr. 2020

0 Stimmen

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

1 Kommentar

Abdulrahman Ghannam
Abdulrahman Ghannam am 16 Apr. 2020
I will try to implement this in my code, thank you for your help. Appreciated

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Board games finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019b

Gefragt:

am 15 Apr. 2020

Bearbeitet:

am 17 Apr. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by