Problem 44508. Curve fitting (non-linear functions) & function handles
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 user-supplied parameters produce from the user-supplied 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
Aha--I 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
-
1329 Solvers
-
How to find the position of an element in a vector without using the find function
2632 Solvers
-
Rotate and display numbered tile
340 Solvers
-
97 Solvers
-
How many days does the cat take to climb out of the hole?
75 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!