Convert excel file data from char to number or double

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 Comments

It is simpler to use the first output of xlsread, which is already numeric.
Although given that some beginners apparently confuse CSV text files with proprietary Excel file formats (e.g. .xls, xlsx, etc), perhaps all you need is to use csvread, or dlmread, or readtable, or readcell, or readmatrix, or the like.
In any case, we don't know until you upload a sample file by clicking the paperclip button so that we can check the actual file format.
|
Thank you Stephen. This Is the file in CSV format. I want to convert all the elements to number or double in other to use the neuro fuzzy designer to train and test the data.
Whjat is this function char2double?

Sign in to comment.

Answers (2)

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)
Thank you all for your contributions this really help.

Products

Release

R2017a

Asked:

on 28 Mar 2019

Answered:

on 29 Mar 2019

Community Treasure Hunt

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

Start Hunting!