saving a .csv file with text values as a .mat file

2 ビュー (過去 30 日間)
Apurva Jariwala
Apurva Jariwala 2019 年 2 月 19 日
コメント済み: Apurva Jariwala 2019 年 2 月 19 日
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.. ?

採用された回答

Walter Roberson
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.
  1 件のコメント
Apurva Jariwala
Apurva Jariwala 2019 年 2 月 19 日
Thank you very much!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by