Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Simple MATLAB ODE45 Problem So What I want is a MATLAB code for (a) -Graph of ho

ID: 1424326 • Letter: S

Question

Simple MATLAB ODE45 Problem

So What I want is a MATLAB code

for (a)

-Graph of horizontal and vertical location using ODE45 code

for (b)

-Graph of horizontal and vertical location using ODE45 code

I will still give you guys a credit if you guys answer (a)

The MASS, GRAVITY, Time Range, initial location of x direction and y direction

You guys can choose any number you want for the values above

Don't consider the surface of the object

1. Let the projectile's path be given by r(t)-r(t)i + y(t)j relative to the firing position at the origin. The position r(t) can be determined by solving the second-order vector differential equation described by Newton's Law F = mr where we account only for gravitational and drag forces on the projectile, assuming there is no wind blowing. To start, we can write Newton's Law as F = mv, where v = r. (Note that we have just turned the second-order vector ODE into two coupled first-order vector ODEs.) (a) Write the components of the projectile's velocity v(t) = r(t) = x(t)it (t)j in polar form to show that r=u cos(0) and y= u sin(0), where v(t) = |v1 = VET is the speed of the projectile, and (t) is the angle of its motion measured in the counterclockwise direction from the horizontal z-axis (b) mv written in terms of the local TNB frame of reference. Compare Now think of F the normal and tangential components of F = mv along the projectile's path to arrive at the following relations Cmr-gsin(0) and =--cos(), where m is the mass of the projectile, g is the acceleration due to gravity, and C is the drag coefficient such that the magnitude of the drag force is proportional to the square of the speed of the projectile. The drag force itself acts in the opposite direction of the velocity vector, v. You may assume that the drag coefficient C is a measurable constant (c) For the first project, you will need to find the projectile's location at any time, r(t) and hence solve (1) and (2) as a system of four coupled first-order differential equations subject to some appropriate initial conditions. What are these initial conditions?

Explanation / Answer

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%% function containing the differential equation %%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function dy=my_fun(t,y) % y is a matrix containing [x y v theta]
global Cd
global m
dy=zeros(4,1);
dy(1)=y(3)*cos(y(4)); % x'=v*cos(theta)
dy(2)=y(3)*sin(y(4)); % y'=v*sin(theta)
dy(3)=(-Cd*(y(3)).^2/m)-9.8*sin(y(4));
dy(4)=-9.8*cos(y(4))./y(3);
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%% main function %%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

global Cd
global m
g=9.8;
m=input('enter mass of projectile ');
Cd=input('enter drag coefficient ');
v0=input('enter initial velocity ');
theta0=input('enter initial angle with horizontal ');
[T Y]=ode45(@my_fun,[0 5],[0 0 v0 theta0]);
figure(1)
plot(T,Y(:,1))
grid on
xlabel('time (in seconds)')
ylabel('horizontal position (in m)')
title('plot of horizontal location vs time')

figure(2)

plot(T,Y(:,2))
grid on
xlabel('time (in seconds)')
ylabel('vertical position (in m)')
title('plot of vertical location vs time')

figure(3)
plot(Y(:,1),Y(:,2))
grid on
title('vertical location vc horizontal location')

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote