The test-suite is incorrectly programmed. Isequal does not work for nan's:
isequal(nan,nan) is never true.
Furthermore, the line "if n=1" is an incorrect statement.
J.G. is right!! please correct it!
Dear all,
You can make use of 'isnan'
Try.
It can be solved...
use 'isequaln'
NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN...
Batman?
the other commenters are right. see: http://www.mathworks.com/help/matlab/ref/isequalwithequalnans.html
Still, the open "if" statement in the test suite will not pass any solutions. Consider making "n" an argument?
the problem can be solved, but the test suite has bugs like everyone else commented. please fix the open "if" and isequal on NaN's i.e. assert(isequal(y_correct, y_correct)) does not pass in the second test.
Is it fine now?
Not quite. You will still need to use "isequalwithequalnans" (or "isequaln" in newer versions) instead of "isequal".
I updated the test suite with the suggestions made here. I believe it works now.
The particular number is 1
This problem would be much better if the "particular number" was one of the arguments to the function.
I wrote this solution when there were multiple problems with the test suite. It's an ugly hack, and not a "real" solution. Now that the test suite is working, please ignore this solution.
28053 Solvers
Find all elements less than 0 or greater than 10 and replace them with NaN
13064 Solvers
669 Solvers
Create matrix of replicated elements
322 Solvers
Number of digits in an integer
336 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!