x Turn on thread page Beta

# Matlab Help!! watch

1. Any help would be great, i have tried everything i Just need to know how to do t now its driving me insane!!
a) The position of a projectile fired at a height h from the ground and at an angle 
will be given at time t by,
𝑥(𝑡) = 𝑣0 cos() 𝑡
𝑦(𝑡) = ℎ + 𝑣0 sin() 𝑡 −
1
2
𝑔𝑡
2
Write a script to calculate the x and y positions for different times and plot the
trajectories. You don’t want to plot for negative values of y (i.e. after the projectile
has landed), so make sure the vectors for x and y only contain the required data.
(HINT: think loops!) Find the position of the last element, where y=0 (or is close
to it), and use this to determine the range of the projectile. Show some plots for
h=0, for a couple of different values of .
b) Find the range of the projectile for a couple of different values of . What are the
limitations to the accuracy of your result? How could the accuracy be improved?
Repeat part (b) for a couple of different values of h and see how the best launch
angle changes as the launch height changes. Can you spot a trend for the optimal
angle as you launch from greater heights?
c) (HARD!) The equations above neglect friction due to the projectile’s interaction
with the air. An equation for friction can be given by,
𝑓𝑑 = 𝑐𝑣
2
where fd is the friction force, v is the velocity and c is a constant which accounts
for the area and mass of the projectile and the drag coefficient of the air.
Include the drag force in your script. The force will need to be calculated in small
steps and then added to the acceleration. The force will be in the direction of
projectile travel, so at each step you will need to convert vx and vy into vr. (A
function has been provided for this.)
You can use an equation like,
𝑓𝑑 =
𝛿𝑣𝑟
𝛿𝑡

to calculate the change in velocity, vr during a small time step δt.
Investigate which values of c give realistic looking trajectories.

Heres what i have so far:

>> %constant values
A=30 %angle
v=1 %velocity
h=0 %height
g=9.81; %acceleration due to gravity

A =

30

v =

1

h =

0

>> %initial variable values
time=0; %time
y=h %vertial value
x=0 %horizontal value
k=1 %number of term of function

y =

0

x =

0

k =

1

>> while y>=0
time=time+0.01; %increases time value by 0.01 for each repetition
x(k)=v*cosd(A)*time; %calculates x values and saves them as an array
y(k)=h+v*sind(A)*time-0.5*g*time^2; %calculates y values and saves them as an array
k=k+1; %increases k value by 1 each repetition
end
x(k-1)
plot(x,y)

ans =

0.0953

TSR Support Team

We have a brilliant team of more than 60 Support Team members looking after discussions on The Student Room, helping to make it a fun, safe and useful place to hang out.

This forum is supported by:
Updated: March 3, 2016
Today on TSR

### Four things top students are doing

Over the Easter break

### Her parents made her dump me

Poll

The Student Room, Get Revising and Marked by Teachers are trading names of The Student Room Group Ltd.

Register Number: 04666380 (England and Wales), VAT No. 806 8067 22 Registered Office: International House, Queens Road, Brighton, BN1 3XE