Problem 300. Remove NaN ?
Solution Stats
Problem Comments
-
2 Comments
Additional test cases have been added.
I have the same problem and need a solution.
Solution Comments
-
1 Comment
you can use find function... easy
-
2 Comments
function y = removeNaN(x)
[n m] = size(x);
for i = 1 : n
maxx = max(isnan(x(i,:)));
if maxx ~= 1
y = (x(i,:))
end
end
What is Wrong With THis Code CAn SomeOne Tell ME
It looks like y will return only the last non-NaN row, instead of collecting all of them.
-
1 Comment
Very nice!!
-
1 Comment
This solution doesn't necessarily work if there are any Inf elements in the matrix. Perhaps it would be best to add a test case where that is the case.
Problem Recent Solvers983
Suggested Problems
-
5154 Solvers
-
Increment a number, given its digits
610 Solvers
-
We love vectorized solutions. Problem 1 : remove the row average.
751 Solvers
-
Create an n-by-n null matrix and fill with ones certain positions
476 Solvers
-
408 Solvers
More from this Author10
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!