Problem 2803. Split up vector or matrix delimited by NaNs
Solution Stats
Problem Comments
-
4 Comments
The problem suite doesn't function properly. The following statement is the culprit:
assert(isequal(c = split_nan_delimited(x), y_correct))
and can be changed to:
assert(isequal(split_nan_delimited(x), c_correct))
for all the test cases.
Furthermore, do not test for emptiness with isequal. Use isempty instead. There are many ways to generate empty cell arrays and matrices in Matlab, none of which are equal with isequal.
Doh! Embarrassing copy paste error. I hope it's all fixed now.
Test 10 still test for emptiness with isequal.
Solution Comments
-
4 Comments
'ans' bug? It seems that the output is not assigned correctly to ans. Solutions 559047 ...48 ...50 work.
To be more specific, several expressions does't return anything when the output is not specified. for example: cellfun(@nnz,{}); does't change the value of ans while: ans=cellfun(@nnz,{}); does (and ans = {})
Is that a bug on 'ans' or 'cellfun'?
it occurs for both arrayfun and cellfun, seems to be problem with ans. Here is an old topic on answers: http://uk.mathworks.com/matlabcentral/answers/46972-is-this-a-possible-matlab-bug-further-strange-behavior
btw. I've written "does (and ans = {})", should be "does (and ans = [])"
Problem Recent Solvers14
Suggested Problems
-
Find state names that start with the letter N
946 Solvers
-
268 Solvers
-
89 Solvers
-
Get the length of a given vector
6525 Solvers
-
Fix the last element of a cell array
735 Solvers
More from this Author4
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!