Simple matlab interpolation help

  • MATLAB
  • Thread starter JXPES
  • Start date
  • #1
2
0

Main Question or Discussion Point

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.
 

Answers and Replies

  • #2
2
0
never mind. worked it out- the order of the intervals had to be considered
 

Related Threads for: Simple matlab interpolation help

  • Last Post
Replies
9
Views
34K
  • Last Post
Replies
0
Views
7K
Replies
4
Views
4K
  • Last Post
Replies
0
Views
5K
Replies
5
Views
2K
Replies
1
Views
12K
Replies
1
Views
6K
Top