Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB Need Help with Numerical Integration in MATLAB

  1. Nov 15, 2008 #1
    Here is an integral (similar in form to the one) I want to evaluate:

    [tex]\int_{r_1}^{r_2}R \left\vert{\int_{x_1}^{x_2}Y(x,R) dx \right\vert^2 dR[/tex]

    This is my approach - please correct me because I don't think it's right:
    I treat R as a constant and evaluate the inner integral over some vector of x (using the function "trapz" in MATLAB)
    I do the same thing again for another value of R (until the range of R values are done). Ending up with an array of values for the inner integral. (Where each element corresponds to the integral of a particular value of R).
    Lastly, I evaluate the outer integral (with "trapz") over the same vector of R but for each value of the inner integral.

    What do you think?
  2. jcsd
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted