It's a good problem!
very good problem
ya.. but not so difficult though
nice trick with the " ' "))
very good problem
I really like this problem. It makes me to improve my solutions again and again. But it seems that I still use too many loops....
lol test case with transform was good one!
do not understand how one get so efficient solution on this (and to be honest other problems as well)
thanks you very much.
Why doesn't this work? It works when I use it on my computer...
function B = remove_nan_rows(A)
B = A;
B(any(isnan(A')),:) = [];
end
MATLABotic!
These types of problems are giving me so many useful functions
A(~sum(isnan(A),2),:) this workde for me
Cool!
Very good problem!
A easy problem if you know fuction isnan.
Nice one!
Oh
Easy one
My solution is correct....i checked in MATLAB. You need to fix bugs
SHABI
I like problems with logic solutions.
two NaNs are not equal to each other, using isnan to detect NaNs. Thus,
a = a(all(a==a,2),:);
a = a(~any(isnan(a),2),:);
a(any(a~=a,2),:) = [];
a(any(isnan(a),2),:) = [];
really cool!
I think that test 4 does not comply to the question.
A(~sum(isnan(A),2),:) this worked for me
O(^-^) o
function B = remove_nan_rows(A)
B = A;
B(any(isnan(A')),:) = [];
end
Why isn't this working?
I like the solution
a = a(all(a==a,2),:); % a = a(~any(isnan(a),2),:);
a(any(a~=a,2),:) = []; % a(any(isnan(a),2),:) = [];
来自知乎
If I can't view a smaller solution, how can I improve myself ??
I really want to view the better answers.
The only improvement you can really make is making it one line
B = A( not( any(isnan(A), 2 ), :)
really?
I really liked this problem. I know that I took a very long approach to it but in time I hope to improve it. I have had a lot of practice with for and while loops which is why I have taken this approach.
i am unable to compare it with inf. how can i do that??
Can anyone tell me why matrix B is not being returned correctly? If I put it one 'end' further into the loop it returns the matrix each time a row is taken out and the tests fail
when you delete one row of B, the size of B changes.
your solution works with an assumption that the size of B won't change.
2 points better than my previous solution with ~any(isnan(
Passes the defined tests, but would fail if Inf was in the test matrices.
Can anyone please tell me how to reduce this size?
You already use vectorized assignment. Carry that further and get rid of the for loop.
The functions sum() and prod() can reduce row-wise to bring out NaN values. Thus, this express produces logicals for whether each row is in or out...
~isnan(prod(A,2))
Can anyone tell me, how it can coded in size of 10???
Using regexp, you can put all the code into a character string, and the character string only has a size of 1.
Good one...
Would fail if test suite contained any Infs.
^ Yes, this happens to work on the test inputs, but is technically not doing what the problem asks.
On the other hand, B = A(all(A==A,2),:) works.
842 Solvers
824 Solvers
605 Solvers
Back to basics - mean of corner elements of a matrix
315 Solvers
572 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!