Convert excel file data from char to number or double

6 Ansichten (letzte 30 Tage)
Jemirade Ayobami
Jemirade Ayobami am 28 Mär. 2019
Beantwortet: Jemirade Ayobami am 29 Mär. 2019
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
Jemirade Ayobami
Jemirade Ayobami am 29 Mär. 2019
Sorry xlsx format.
KSSV
KSSV am 29 Mär. 2019
Whjat is this function char2double?

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Walter Roberson
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)

Jemirade Ayobami
Jemirade Ayobami am 29 Mär. 2019
Thank you all for your contributions this really help.

Produkte


Version

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by