Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Interpreting MATLAB's in-built trapezoidal rule

Subject: Interpreting MATLAB's in-built trapezoidal rule

From: Jac

Date: 28 Sep, 2012 05:44:09

Message: 1 of 3

Hey all,
I am faced with this task:
Extract the world population growth rate date from “Population Growth Rate.csv”.
Given that the initial population at year 1950 is 2532229237. Integrate the world
population growth rate from 1950-2010 at 1 year interval to obtain the world’s
population. You should apply cumulative integration using trapezoidal rule.

The growth rate numerical data are all percentages, and range from 0 to 2.
After fiddling around i get a row vector with 61 columns.

If I call my row vector A
and then go:
B = trapz(A)

I get an answer of approx 99.9.

What does this answer signify and how do i apply it to find the population for 2010?

Any help to greater my understanding would be muchly appreciated. Thanks!

Subject: Interpreting MATLAB's in-built trapezoidal rule

From: Kristin

Date: 2 Oct, 2012 05:01:08

Message: 2 of 3

"Jac " <jac_domney@hotmail.com> wrote in message <k43df8$bt7$1@newscl01ah.mathworks.com>...
> Hey all,
> I am faced with this task:
> Extract the world population growth rate date from “Population Growth Rate.csv”.
> Given that the initial population at year 1950 is 2532229237. Integrate the world
> population growth rate from 1950-2010 at 1 year interval to obtain the world’s
> population. You should apply cumulative integration using trapezoidal rule.
>
> The growth rate numerical data are all percentages, and range from 0 to 2.
> After fiddling around i get a row vector with 61 columns.
>
> If I call my row vector A
> and then go:
> B = trapz(A)
>
> I get an answer of approx 99.9.
>
> What does this answer signify and how do i apply it to find the population for 2010?
>
> Any help to greater my understanding would be muchly appreciated. Thanks!

Wikipedia is a good place to start to learn more about the trapezoidal rule. Also, the function you call, TRAPZ, is pretty short and seems easy enough to read. Type "edit trapz" into the command line and check it out!

I have not looked at the function, but I assume it uses a composite trapezoid rule for the points you feed it (given by the row vector). So for some points, you have the solution of the integral (area under the curve ~ 99.9).

For the next question, we have integral(f(x), dx, 1950, 2010) = F(2010) - F(1950), where F'(x) = f(x) (see: Fundamental Theorem of Calculus). Then you have the solution of the integral as well as F(1950), that is, the population in 1950, so there ya go.

Subject: Interpreting MATLAB's in-built trapezoidal rule

From: Roger Stafford

Date: 2 Oct, 2012 23:36:08

Message: 3 of 3

"Jac " <jac_domney@hotmail.com> wrote in message <k43df8$bt7$1@newscl01ah.mathworks.com>...
> Given that the initial population at year 1950 is 2532229237. Integrate the world
> population growth rate from 1950-2010 at 1 year interval to obtain the world’s
> population. You should apply cumulative integration using trapezoidal rule.
> The growth rate numerical data are all percentages, and range from 0 to 2.
- - - - - - - - -
  If your growth rate data is given as a percentage, presumably it refers to a percentage per year of the current total population, which in turn means you are actually faced with a differential equation to solve.

  Let p(t) be the population at t years and r(t) be the percentage rate of growth per year of the population at t years. The appropriate differential equation would be:

 dp(t)/dt = r(t)/100*p(t)

  This is a very easy differential equation to solve as can be seen by dividing by p(t):

 1/p(t)*dp(t)/dt = d(log(p(t))/dt = r(t)/100

If you integrate this with respect to t, then you get

 log(p(2010))-log(p(1950)) = integral of r(t)/100 w.r. to t, t=1950:2010

You can use trapezoidal integration to find the right side, and then solve this equation for p(2010).

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us