Please, bmtran, don't use isequal with floats, prefer to use abs(a-b) < tol. Unless I use the function interp1 exactly like you did, my solution cannot pass the test suite. Please try my commented code (and the difference between the solutions is at the order of 1e-15).
perhaps you could specify a target numerical precision? (isequal on floats can be flaky)
Alfonso's solution suffers from the same problem of precision apparently. Using isequal requires that one does the exact same operation that you did (to obain the exact same error*), and closes the door for alternative or smaller solutions.
* Floating-point numbers have some precision problems: the classic example is 0.1 which becomes an infinite number as a binary.
Rotate and display numbered tile
Convert hex color specification to MATLAB RGB
All Humans are Created Equal - Pareto Equality
Get the length of a given vector
Compute a dot product of two vectors x and y
Great Circle Distance
Determine if a Given Number is a Triangle Number
Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Test if a Number is a Palindrome without using any String Operations
Triangle Numbers Below N
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