Raquel - the MATLAB debugger is helpful in cases like this. If you put a breakpoint in your simpson13 you would notice a problem with the input parameter f. Look closely at how it is being assigned
x=0;
n=6; % n is the number of intervals and must be > 0 and even
a=0; b=pi;% a is the lower bound and b is the upper bound
f=5+13*sin(x); % Function
f is not a function in this case but is a scalar value (5) since x is zero. If you want f to be an anonymous function then you need to assign it as
f = @(x)5+13*sin(x);
where nthe @ operator creates the handle, and the parentheses () immediately after the @ operator include the function input arguments. You will need to change how this function is used in your code as well. For example,
Best Answer