saving a .csv file with text values as a .mat file
2 views (last 30 days)
Show older comments
Apurva Jariwala
on 19 Feb 2019
Commented: Apurva Jariwala
on 19 Feb 2019
I tried using csvread, but it only accepts csv files with numeric values. I want to convert a csv file e.g. fisheriris.csv to .mat file, how can i do that?
Also, how to change the class labels with numbers or letters like a,b,c.. ?
0 Comments
Accepted Answer
Walter Roberson
on 19 Feb 2019
T = readtable('fisheriris.csv');
Tlabcat = categorical(T{:,5});
Tcats = categories(Tlabcat);
Tlabnum = double(Tlabcat);
Tnum = [T{:,1:4}, Tlabnum];
Now Tcats is a cell array of character vectors indicating the category names, and Tnum is a double array of the data, with the last column being a class number converted from the text category labels.
More Answers (0)
See Also
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!