1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Homework Help: MATLAB help

  1. Jan 19, 2010 #1
    1. The problem statement, all variables and given/known data
    A modified form of the trapezium rule for calculating the area under a curve makes use of strips
    of varying width: by using narrower strips where the gradient varies more rapidly, better
    accuracy can be achieved. Create a function to perform the integral

    [tex]\int1/x dx[/tex] between 1 and 101

    using the trapezium rule with strips that increase geometrically in width, such that,

    [tex]\Delta[/tex]Xn=rn-1[tex]\Delta[/tex]X1 where [tex]\Delta[/tex]Xn is the width of the nth strip and r is a constant (which is an
    input to the function).
    Choose the value of Δx1 to give a total of 100 strips for any value of r (hint: you will need the
    formula for the sum of a geometric progression to calculate Δx1).

    2. Relevant equations

    3. The attempt at a solution

    Not sure where to start really, I mean a simple application of the trapezium rule to it would be simple enough. Define a vector x=[1:1:101] and then y=1./x and integral=trapz(x,y) or something along those lines (I don't have access to MATLAB from home so I couldn't be sure). Any point in the right direction would be much appreciated.
    Last edited: Jan 19, 2010
  2. jcsd
  3. Dec 25, 2010 #2
    Did you ever find an answer to this question?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook