Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Solution 293751

Submitted on 1 Aug 2013 by Aditya Suryavanshi

Correct

54Size
Leading solution size is 10.
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test
Code Input and Output
1
Pass
 
%%
x = magic(3);x(2,[1 3])= NaN;
y_correct = [8 1 6;4 9 2];
assert(isequal(removeNaN(x),y_correct))
ans =
     1
     0
     1
ans =
     1     1     1
     0     0     0
     1     1     1
ans =
     8
     4
     1
     9
     6
     2
ans =
     8     1     6
     4     9     2
2
Pass
 
%%
x = [magic(4) ones(4,1)];
x(4,5) = NaN;x(3,2) = Inf;x(3,1)=NaN;
y_correct = x(1:2,:);
assert(isequal(removeNaN(x),y_correct))
ans =
     1
     1
     0
     0
ans =
     1     1     1     1     1
     1     1     1     1     1
     0     0     0     0     0
     0     0     0     0     0
ans =
    16
     5
     2
    11
     3
    10
    13
     8
     1
     1
ans =
    16     2     3    13     1
     5    11    10     8     1