Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Octave: Help with implementing midpoint rule

  1. Feb 4, 2010 #1
    I got the code from my textbook and it is supposed to work in matlab
    Code (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));
    The code fails on feval

    I go tcnchk from wikipedia
    Code (Text):
    function f=fcnchk(x, n)
      f = x;
    and I use f = 'x.^2' as f

    Can someone help me?
    I don't know how to copy the error from Octave
  2. jcsd
  3. Feb 4, 2010 #2


    Staff: Mentor

    How about you look at the error and write it down, then post it here?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook