Program projectile motions using MATLAB as below. Figure 01. A sample multi-traj
ID: 656511 • Letter: P
Question
Program projectile motions using MATLAB as below. Figure 01. A sample multi-trajectory graph when initial velocity is 30 m/s. These plots are just examples. You have to input function to initialize the launching velocity g) 30 m/s in figure 01 and use for-loop to create multiple angles starting from 0 to 90 degrees with 5 degree increment. The plot command goes inside of the for-loop and use the command, hold on to see multiple plots in a single figure window. Once you code and run the program, save your m-file with the first initial of your first name and last name.Explanation / Answer
function vend = velocity1(dt, ti, tf, vi)
velocity1: Euler solution for bungee velocity
vend
input: dt= ti= tf= vi=
= velocity1(dt, ti, tf, vi)
Euler method solution of bungee jumper velocity
time step (s)
initial time (s)
final time (s)
initial value of dependent variable (m/s)
output:
vend = velocity at tf (m/s)
= ti; = vi;
n = (tf - ti) / dt; for i = 1:n
dvdt = deriv(v); v = v + dvdt * dt; t = t + dt;
end
vend = v; end
function dv = deriv(v)
dv = 9.81 - (0.25 / 68.1) * v*abs(v); end
This function can be invoked from the command window with the result:
>> velocity1(0.5,0,12,0)
ans = 50.9259
Note that the true value obtained from the analytical solution is 50.6175 (Exam- ple 3.1). We can then try a much smaller value of dt to obtain a more accurate numeri- cal result:
>> velocity1(0.001,0,12,0)
ans = 50.6181
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.