- #1
MaxManus
- 277
- 1
I got the code from my textbook and it is supposed to work in matlab
The code fails on feval
I go tcnchk from wikipedia
and I use f = 'x.^2' as f
Can someone help me?
I don't know how to copy the error from Octave
Code:
function r = midpoint(a,b,f,n)
f = fcnchk(f);
h = (b-a)/n;
x = (a+h*0.5):h:(b-h*0.5);
y = feval(f,x);
r = h*sum(y(1:n));
The code fails on feval
I go tcnchk from wikipedia
Code:
function f=fcnchk(x, n)
f = x;
end
and I use f = 'x.^2' as f
Can someone help me?
I don't know how to copy the error from Octave