Problem 44507. Curve fitting (linear functions) & function handles
Solution Stats
Problem Comments
-
2 Comments
It might be nice to replace assert(isequal(y,y_correct)) by something along the lines of assert(max(abs(y-y_correct))<1e-9) to allow for roundoff errors.
Hello, Tim. Thank-you for your suggestion. Although it hadn't been mentioned, _all_ of the relevant numbers (x(i), y(i), m and c) are integers, so I didn't expect rounding would be a problem. [Certainly it wasn't in my reference code.] In any case, the secondary application I had in mind was lossless compression, so I am not keen to change the assertions in this particular problem (although I agree that often, elsewhere, it is indeed good to implement assertions as in your snippet). I will instead add a note to the Problem Statement. —David
Problem Recent Solvers8
Suggested Problems
-
Back to basics 6 - Column Vector
979 Solvers
-
468 Solvers
-
Find Index of maximum Value and maximum Value of a vector
147 Solvers
-
I've got the power! (Inspired by Project Euler problem 29)
97 Solvers
-
303 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!