Cody

# Problem 43751. Remove Missing Values from a Table or an Array

Solution 2207872

Submitted on 13 Apr 2020 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
1 x = [1 3 NaN 6 NaN]; y_correct = [1 3 6]; assert(isequal(your_fcn_name(x),y_correct))

ans = 1

2   Pass
2 x = [1 3 NaN 6 NaN;6 3 1 5 2; NaN 1 2 3 4; 1:5; 5:-1:1]; y_correct = [6 3 1 5 2; 1:5; 5:-1:1]; assert(isequal(your_fcn_name(x),y_correct))

ans = 2

3   Pass
3 x = [1 3 NaN 6 NaN]; y_correct = [1 3 6]; assert(isequal(your_fcn_name(x),y_correct))

ans = 3

4   Pass
4 x = table(categorical({'';'F';'M'}),[45;32;NaN],{'';'CA';'MA'},[6051;7234;NaN],... 'VariableNames',{'Gender' 'Age' 'State' 'ID'}) y_correct = table(categorical({'F'}),[32],{'CA'},[7234],... 'VariableNames',{'Gender' 'Age' 'State' 'ID'}) assert(isequal(your_fcn_name(x),y_correct))

ans = 4 x = 3x4 table <strong>Gender</strong> <strong>Age</strong> <strong>State</strong> <strong>ID</strong> <strong>___________</strong> <strong>___</strong> <strong>__________</strong> <strong>____</strong> <undefined> 45 {0×0 char} 6051 F 32 {'CA' } 7234 M NaN {'MA' } NaN y_correct = 1x4 table <strong>Gender</strong> <strong>Age</strong> <strong>State</strong> <strong>ID</strong> <strong>______</strong> <strong>___</strong> <strong>______</strong> <strong>____</strong> F 32 {'CA'} 7234

5   Pass
5 dblVar = [2;3;5;7;9;11]; singleVar = single([1;NaN;5;7;9;11]); cellstrVar = {'one';'three';'four';'seven';'nine';'eleven'}; charVar = ['A';'C';'E';'G';'I';'J']; categoryVar = categorical({'red';'yellow';'blue';'violet';'';'ultraviolet'}); m = [1:2:10]; dateVar = [datetime(2015,m,15) NaT]'; x = table(dblVar,singleVar,cellstrVar,charVar,categoryVar,dateVar) dblVar = [2;5;7]; singleVar = single([1;5;7]); cellstrVar = {'one';'four';'seven'}; charVar = ['A';'E';'G']; categoryVar = categorical({'red';'blue';'violet'}); m = [1 5 7]; dateVar = [datetime(2015,m,15)]'; y_correct = table(dblVar,singleVar,cellstrVar,charVar,categoryVar,dateVar) assert(isequal(your_fcn_name(x),y_correct))

ans = 5 x = 6x6 table <strong>dblVar</strong> <strong>singleVar</strong> <strong>cellstrVar</strong> <strong>charVar</strong> <strong>categoryVar</strong> <strong>dateVar</strong> <strong>______</strong> <strong>_________</strong> <strong>__________</strong> <strong>_______</strong> <strong>___________</strong> <strong>___________</strong> 2 1 {'one' } A red 15-Jan-2015 3 NaN {'three' } C yellow 15-Mar-2015 5 5 {'four' } E blue 15-May-2015 7 7 {'seven' } G violet 15-Jul-2015 9 9 {'nine' } I <undefined> 15-Sep-2015 11 11 {'eleven'} J ultraviolet NaT y_correct = 3x6 table <strong>dblVar</strong> <strong>singleVar</strong> <strong>cellstrVar</strong> <strong>charVar</strong> <strong>categoryVar</strong> <strong>dateVar</strong> <strong>______</strong> <strong>_________</strong> <strong>__________</strong> <strong>_______</strong> <strong>___________</strong> <strong>___________</strong> 2 1 {'one' } A red 15-Jan-2015 5 5 {'four' } E blue 15-May-2015 7 7 {'seven'} G violet 15-Jul-2015

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!