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
Find all elements less than 0 or greater than 10 and replace them with NaN
Reverse Run-Length Encoder
Vector parallel to plane?
Matrix multiplication across rows
Hard limit function
Guess the number I'm thinking of
Arrange the names in alphabetical order (1)
The twelve days of Christmas
Make your own Test Suite (part 2)
Make your own Test Suite (part 3)
Find the treasures in MATLAB Central and discover how the community can help you!
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Contact your local office