I got the code from my textbook and it is supposed to work in matlab(adsbygoogle = window.adsbygoogle || []).push({});

The code fails on fevalCode (Text):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));

I go tcnchk from wikipedia

and I use f = 'x.^2' as fCode (Text):function f=fcnchk(x, n)

f = x;

end

Can someone help me?

I don't know how to copy the error from Octave

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Octave: Help with implementing midpoint rule

**Physics Forums | Science Articles, Homework Help, Discussion**