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

Simple matlab interpolation help

  1. Dec 26, 2011 #1
    suppose I have a function f(x) which I know increases as x.

    I'm trying to combine a for loop and if statement

    x(1)=a;
    x(2)=b;
    x(3)=(a+b)/2;

    for i=3:n
    if f(x(i)) > A
    x(i+1) = (x(i-2)+x(i))/2;
    else
    x(i+1) = (x(i-1)+x(i))/2
    end
    end

    this method works for x(4), the rest come with errors! Am I missing something obvious? Thanks.
     
  2. jcsd
  3. Dec 26, 2011 #2
    never mind. worked it out- the order of the intervals had to be considered
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Simple matlab interpolation help
  1. Matlab- interpolation (Replies: 0)

  2. Simple MATLAB help (Replies: 1)

Loading...