function y = removeNaN(x)
y=x;
[a,~]=find(isnan(x));
y(a,:)=[];
end
Test | Status | 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))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint1 (line 3)
In solutionTest (line 3)]
|
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))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint2 (line 4)
In solutionTest (line 5)]
|
3 | Pass |
x = ones(4);x(3,3)=NaN;
y_correct = ones(3,4);
assert(isequal(removeNaN(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint3 (line 3)
In solutionTest (line 7)]
|
4 | Pass |
x = [1; NaN];
y_correct = [1];
assert(isequal(removeNaN(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint4 (line 3)
In solutionTest (line 9)]
|
5 | Pass |
x = NaN;
assert(isempty(removeNaN(x)))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint5 (line 2)
In solutionTest (line 11)]
|
6 | Pass |
x = [1:10 NaN];
assert(isempty(removeNaN(x)))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint6 (line 2)
In solutionTest (line 13)]
|
7 | Pass |
x = [1:10 NaN]';
y_correct = [1:10]';
assert(isequal(removeNaN(x),y_correct))
[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.]
[> In unix (line 32)
In removeNaN (line 1)
In ScoringEngineTestPoint7 (line 3)
In solutionTest (line 15)]
|
Find all elements less than 0 or greater than 10 and replace them with NaN
13048 Solvers
289 Solvers
Replace multiples of 5 with NaN
358 Solvers
260 Solvers
307 Solvers
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!