I'm new to MATLAB and I'm having a really hard time converting an algorithm that I constructed, into code in MATLAB. Can anyone please help me?
Here is my problem and algorithm: Romberg Integration
To approximate the integral I = integral from a to b of f(x) dx, select an integer n>0.
INPUT: endpoints a,b; integer n OUTPUT: an array R. (Compute R by rows; only the last 2 rows are saved in storage.) Step 1: Set h=b-a; R_(1,1) = h/2((f(a)+f(b)). Step 2: OUTPUT(R_(1,1)). Step 3: For i=2,...,n do Steps 4-8. Step 4: Set R_(2,1) = 1/2[R_(1,1)+h*(sum from i=1 to 2^(i-2) of f(a+(k-0.5)*h)) (Approximation from Trapezoidal Method) Step 5: For j=2,...,i set R_(2,j)=R_(2,j-1)+(R_(2,j-1)-R_(1,j-1))/(4^(j-1)-1). (Extrapolation). Step 6: OUTPUT (R_(2,j) for j=1,2,...,i). Step 7: Set h = h/2. Step 8: For j=1,2,...,i st R_(1,j) = R_(2,j). Step 9: STOP
Thanks in advance.