# Need Help with Numerical Integration in MATLAB

1. Nov 15, 2008

### n0_3sc

Here is an integral (similar in form to the one) I want to evaluate:

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

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?