suppose I have a function f(x) which I know increases as x.(adsbygoogle = window.adsbygoogle || []).push({});

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.

**Physics Forums - The Fusion of Science and Community**

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

# Simple matlab interpolation help

Loading...

Similar Threads - Simple matlab interpolation | Date |
---|---|

Simple MATLAB loop | Oct 30, 2015 |

Coding up a simple geometric algebra in MATLAB | Oct 12, 2015 |

[MATLAB] Simple Undamped Forced Vibration Problem | Jul 31, 2014 |

Having difficult time trying to plot a simple trajecory | May 30, 2014 |

A simple symbolic expression in Matlab | Aug 2, 2013 |

**Physics Forums - The Fusion of Science and Community**