Hello guys, I will work next summer session doing research with a professor and he asked me to do a couple of MATLAB problems using ODE solvers so I can get more familiar since I will be using it. One of the problems is about an object following a projectile motion and I need to solve it using ode15s and then plot the trajectory of the object.(adsbygoogle = window.adsbygoogle || []).push({});

1. The problem statement, all variables and given/known data

The given data for the object mass, initial velocity, angle, and gravity

m = 0.25 kg

v0 = 10 m/s

alpha = 45 degrees

g = 9.81 m/s^2

2. Relevant equations

The system of first order ODEs is the following

y'1= y2

y'2 = 0

y'3 = y4

y'4 = -g/m

Initial Conditions

y1(0) = 0

y2(0) = 0

y3(0) = Vo Cos(alpha)

y4(0) = Vo Sin (alpha)

Attempted Solution

Here is my M-File

function ydot = exercise1(t,y)

ydot = zeros(4,1);

ydot(1) = y(2);

ydot(2) = 0;

ydot(3) = y(4);

ydot(4) = -g/m;

Then on the command window I set up the given data

>> m = 0.25;

g = 9.81;

v = 10;

alpha = pi/4;

a = v*cos(alpha);

b = v*sin(alpha);

I run the program using ode15s and here is the result:

>> [T Y] = ode15s(@exercise1, [0 15], [0 a 0 b])

T =

0

0.0002

0.0004

0.0005

0.0018

0.0030

0.0042

0.0055

0.0161

0.0266

0.0372

0.0478

0.1536

0.2594

0.3653

0.4711

1.5293

2.5876

3.6458

4.7040

6.2040

7.7040

9.2040

10.7040

12.2040

13.7040

15.0000

Y =

1.0e+003 *

0 0.0071 0 0.0071

0.0000 0.0071 0.0000 0.0071

0.0000 0.0071 0.0000 0.0071

0.0000 0.0071 0.0000 0.0070

0.0000 0.0071 0.0000 0.0070

0.0000 0.0071 0.0000 0.0070

0.0000 0.0071 0.0000 0.0069

0.0000 0.0071 0.0000 0.0069

0.0001 0.0071 0.0001 0.0064

0.0002 0.0071 0.0002 0.0060

0.0003 0.0071 0.0002 0.0056

0.0003 0.0071 0.0003 0.0052

0.0011 0.0071 0.0006 0.0010

0.0018 0.0071 0.0005 -0.0031

0.0026 0.0071 -0.0000 -0.0073

0.0033 0.0071 -0.0010 -0.0114

0.0108 0.0071 -0.0351 -0.0529

0.0183 0.0071 -0.1131 -0.0945

0.0258 0.0071 -0.2350 -0.1360

0.0333 0.0071 -0.4009 -0.1775

0.0439 0.0071 -0.7113 -0.2364

0.0545 0.0071 -1.1100 -0.2952

0.0651 0.0071 -1.5970 -0.3541

0.0757 0.0071 -2.1723 -0.4130

0.0863 0.0071 -2.8359 -0.4718

0.0969 0.0071 -3.5877 -0.5307

0.1061 0.0071 -4.3084 -0.5815

I plotted the y versus x

>> plot(Y(:,1),Y(:,3))

the plot is attached so you can see the result, it is supposedly to look as a projectile path but my plot looks like a projectile going all the way down.

if someone can help me to see what I am doing wrong I would be really appreciated

Thank You guys

1. The problem statement, all variables and given/known data

2. Relevant equations

3. The attempt at a solution

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Homework Help: Help with MATLAB problem

**Physics Forums | Science Articles, Homework Help, Discussion**