Question: Numerical Analysis Question Please write the MatLab program for the following function: Note: Make sure the code works. What I have so far: function I
Numerical Analysis Question Please write the MatLab program for the following function: Note: Make sure the code works.

What I have so far:
function I = Simp_int(f,a,b,n) h = (b-a); xi0 = feval('f',a)+feval('f',b); xi1 = 0; xi2 = 0; for i = 1:n-1 x = a+i*h; if mod(i,2) == 0 xi2 = xi2+feval('f',x); else xi1 = xi1+feval('f',x); end end xi = h*(xi0+2*xi2+4*xi1)/3; printf(xi) end
Problem: When I run the program, error: Undefined function or variable 'x'.
Create a function file called Simp-int.m that inputs a function f, a pair of endpoints, a; b and a number n of subintervals, and outputs the approximation to the integral of f from a to b using Simpsons rule on n points. Your function header should look like this function I Simp-int(f,a,b,n)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
