Sie sind auf Seite 1von 7

MATLAB Command Window Page 1

>> readtable('messy.csv','TratAsEmpty',{'.','NA'})
Error using readtable (line 197)
Invalid parameter name: TratAsEmpty.

>> readtable('messy.csv','TreatAsEmpty',{'.','NA'})

ans =

21×5 table

A B C D E
______ ____ _____ ____ ____

'afe1' 3 'yes' 3 3
'egh3' NaN 'no' 7 7
'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
'abk6' 563 '' 563 563
'pnj5' 463 'no' 463 463
'wnn3' 6 'no' 6 6
'oks9' 23 'yes' 23 23
'wba3' NaN 'yes' NaN 14
'pkn4' 2 'no' 2 2
'adw3' 22 'no' 22 22
'poj2' -99 'yes' -99 -99
'bas8' 23 'no' 23 23
'gry5' NaN 'yes' NaN 21

>> summary(T)
Undefined function or variable 'T'.

>> T=readtable('messy.csv','TreatAsEmpty',{'.','NA'})
MATLAB Command Window Page 2

T=

21×5 table

A B C D E
______ ____ _____ ____ ____

'afe1' 3 'yes' 3 3
'egh3' NaN 'no' 7 7
'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
'abk6' 563 '' 563 563
'pnj5' 463 'no' 463 463
'wnn3' 6 'no' 6 6
'oks9' 23 'yes' 23 23
'wba3' NaN 'yes' NaN 14
'pkn4' 2 'no' 2 2
'adw3' 22 'no' 22 22
'poj2' -99 'yes' -99 -99
'bas8' 23 'no' 23 23
'gry5' NaN 'yes' NaN 21

>> summary(T)

Variables:

A: 21×1 cell array of character vectors

B: 21×1 double

Values:
MATLAB Command Window Page 3

Min -99
Median 14
Max 563
NumMissing 3

C: 21×1 cell array of character vectors

D: 21×1 double

Values:

Min -99
Median 7
Max 563
NumMissing 2

E: 21×1 double

Values:

Min -99
Median 14
Max 563

>> TF=ismissing(T,{'' '.' 'NA' NaN -99})

TF =

21×5 logical array

0 0 0 0 0
0 1 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
MATLAB Command Window Page 4

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 1 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 1 0 1 0
0 0 0 0 0
0 0 0 0 0
0 1 0 1 1
0 0 0 0 0
0 1 0 1 0

>> T(any(TF,2),:)

ans =

5×5 table

A B C D E
______ ___ _____ ___ ___

'egh3' NaN 'no' 7 7


'abk6' 563 '' 563 563
'wba3' NaN 'yes' NaN 14
'poj2' -99 'yes' -99 -99
'gry5' NaN 'yes' NaN 21

>> T=standardizeMissing(T,-99)

T=

21×5 table

A B C D E
______ ____ _____ ____ ____

'afe1' 3 'yes' 3 3
MATLAB Command Window Page 5

'egh3' NaN 'no' 7 7


'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
'abk6' 563 '' 563 563
'pnj5' 463 'no' 463 463
'wnn3' 6 'no' 6 6
'oks9' 23 'yes' 23 23
'wba3' NaN 'yes' NaN 14
'pkn4' 2 'no' 2 2
'adw3' 22 'no' 22 22
'poj2' NaN 'yes' NaN NaN
'bas8' 23 'no' 23 23
'gry5' NaN 'yes' NaN 21

>> T2=fillmissing(T,'previous')

T2 =

21×5 table

A B C D E
______ ____ _____ ____ ____

'afe1' 3 'yes' 3 3
'egh3' 3 'no' 7 7
'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
MATLAB Command Window Page 6

'oii4' 5 'yes' 5 5
'wnk3' 245 'yes' 245 245
'abk6' 563 'yes' 563 563
'pnj5' 463 'no' 463 463
'wnn3' 6 'no' 6 6
'oks9' 23 'yes' 23 23
'wba3' 23 'yes' 23 14
'pkn4' 2 'no' 2 2
'adw3' 22 'no' 22 22
'poj2' 22 'yes' 22 22
'bas8' 23 'no' 23 23
'gry5' 23 'yes' 23 21

>> T3=rmmissing(T)

T3 =

16×5 table

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
MATLAB Command Window Page 7

>>