saving a .csv file with text values as a .mat file
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2019-2-19
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.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!