Problem 44508. Curve fitting (nonlinear functions) & function handles
 the handle to a generic function that implements the relevant nonlinear function (i.e. of the form y = mˣ + c) taking two inputs, namely 1 a set of parameters and 2 the vector x, and outputting the corresponding vector y (in any data type); and
 a set of parameter values (m and c) wrapped into a single MATLAB variable (of any data type).
 See also Problem 44507. Curve fitting (linear functions) & function handles — easier.
Solution Stats
Problem Comments

4 Comments
I think you may need to modify some of the tests to "...ensure both odd and even values of x" in all cases where m might be negative.
Hi, Tim. Thanks for your feedback. Actually, from the Player's point of view, m 'could' be negative in any Test. I agree that in some situations there might not be one unique pair of the m & c parameter values that is correct. However, I never apply an assertion to the values of m & c in the Test Suite, rather I check what values of y the usersupplied parameters produce from the usersupplied function(handle). _Any_ valid combination of m & c should be able to REpredict the same values of y provided in the original input, from the same x values (or a subset thereof). There is only one test where I check for prediction of y using x values not included in the original input (extrapolation/interpolation), and for that one test I do have to be careful to ensure there is one unique pair of m & c values that is correct. So I would say this is intentional (I'll add a short note to the Problem Statement). But please let me know if there's a flaw in my logic. —DIV
AhaI see now. To quote Emily Litella: "Never mind."
I should clarify one detail for other Players. Given y = mˣ + c (elementwise), suppose x is the vector [7 8 5 6] and y is the vector [123 123 123 123]. Then there are two valid combinations of m & c, namely m=0 & c=123 and m=1 & c=122. So actually there is not just one unique set of m & c values in this case. However, given x>0 (in the Problem Statement), either of these alternatives can be correctly extrapolated or interpolated from.
Solution Comments
Show commentsProblem Recent Solvers2
Suggested Problems

345 Solvers

Find the elements of a matrix according to a defined property.
83 Solvers

Cody Computer Part 4 : Are you a morning Cody player Addicted ?
81 Solvers

USC Fall 2012 ACM : Code Word Minimum Flipped Bits
18 Solvers

Calculate the probability that at least two people in a group share the same birthday.
93 Solvers
More from this Author32
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!