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?
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Similar Threads - Octave Help implementing Date
Matlab Octave integral computation help Apr 20, 2017
I need help plotting some data using octave Feb 9, 2013
Help with Octave for system of ODEs Dec 10, 2012
Help with Octave Jun 3, 2011
Help with Octave, installing package Mar 31, 2009