Convert excel file data from char to number or double
6 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I have an excel file that contains disease data in char format. I have tried severally to convert from char to number or double.
RecentData = char2double(RecentData); But its not working
4 Kommentare
Antworten (2)
Walter Roberson
am 29 Mär. 2019
T = readtable('Recent data.xlsx');
Then T.AGE will be numeric, and that can also be accessed as T{:,2} .
None of your other fields are numeric, except that you have an empty field just before Result and you could call that emptiness NaN I suppose.
Your other entries are all character vectors. Depending what you want to do with them, you might want to consider using categorical() on them; in most contexts categorical variables can be used as labels. You could also consider things like,
findgroups(T.GeneralMalaise)
which will return a numeric result with group numbers, suitable for routines that need a numeric group label.
My testing suggests that using
temp = categorical(T.GeneralMalaise);
double(temp) %returns numeric code
returns the same numbers as would be returned by
findgroups(T.GeneralMalaise)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Spreadsheets finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!