# Homework Help: Physics problem in MATLAB

1. Feb 22, 2010

### CR3

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

Problem from: A Concise Introduction to MATLAB (McGraw Hill)

pg. 346 # 6

A certain object moves with the velocity v(t) given in the table below:
Determine the object's position x(t) at t= 10s if x(0)= 3

Time (s) = [0,1,2,3,4,5,6,7,8,9,10]

Velocity (m/s) = [0,2,5,7,9,12,15,18,22,20,17]

2. Relevant equations

3. The attempt at a solution

I am having trouble with this problem because I have not had Calculus yet. I think it is a pretty basic Calculus problem but I have very little prior knowledge of Calculus so if anyone could explain this to me I would really appreciate it.

The only way I can think to solve it using what I do know is use the diff(v)./diff(t) equation in MATLAB to find the acceleration and then use the equation x(t) = x(0) + v(0)t + .5at^2 but I am not sure how to type this into MATLAB.

Thanks so much for your help.

2. Feb 22, 2010

### Staff: Mentor

You're going the wrong way - you don't need the acceleration. From the listed velocity values you can calculate distance the object has traveled. As a very simple example, if a car's velocity is 60 mi/hr and it travels at that velocity for two hours, then its position is 120 mi. from its starting position (d = vt).

Your problem is a little more complicated, but not too much more. You are given the instantaneous velocities at each second. At t = 0, v = 0. At t = 1, v = 2. I would estimate the distance as the average of the two velocities, and then multiply by the time elapsed.

Distance (first second) $\approx$ (v(1) - v(1))/(t(1) - t(0)] = (2 - 0)/(1 - 0) = 2. Do the same thing for each 1-second interval, and then add up all of the distances. That will give you the total distance the object has traveled.

3. Feb 22, 2010

### CR3

Thank you so much! This is so helpful!

4. Feb 22, 2010

### Staff: Mentor

What I've suggested is called trapezoidal integration, since you are in effect calculating the area of a bunch of trapezoids.

To get the acceleration, you take the derivative of the velocity, but to get the distance, you integrate the velocity. There are many techniques for numerical integration, of which the trapezoid method is just one.

Share this great discussion with others via Reddit, Google+, Twitter, or Facebook