MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Remove Rows with Missing Values


Create a new table, T3, that contains only the rows from T without missing values. T3 has
only 16 rows.


T3 = rmmissing(T);
disp(T3)


A B C D E




'afe1' 3 'yes' 3 3
'wth4' 3 'yes' 3 3
'atn2' 23 'no' 23 23
'arg1' 5 'yes' 5 5
'jre3' 34.6 'yes' 34.6 34.6
'wen9' 234 'yes' 234 234
'ple2' 2 'no' 2 2
'dbo8' 5 'no' 5 5
'oii4' 5 'yes' 5 5
'wnk3' 245 'yes' 245 245
'pnj5' 463 'no' 463 463
'wnn3' 6 'no' 6 6
'oks9' 23 'yes' 23 23
'pkn4' 2 'no' 2 2
'adw3' 22 'no' 22 22
'bas8' 23 'no' 23 23


T3 contains 16 rows and five variables.


Organize Data


Sort the rows of T3 in descending order by C, and then sort in ascending order by A.


T3 = sortrows(T2,{'C','A'},{'descend','ascend'});
disp(T3)


A B C D E




'abk6' 563 'yes' 563 563
'afe1' 3 'yes' 3 3
'arg1' 5 'yes' 5 5
'gry5' 23 'yes' 23 21
'jre3' 34.6 'yes' 34.6 34.6


Clean Messy and Missing Data in Tables
Free download pdf