Read a column as numbers
3 ビュー (過去 30 日間)
古いコメントを表示
I have a column with a large number of "NA" and a few numbers. When I import this from a csv file using readtable, matlab reads it as cell array. Even table2array returns a cell array instead of double. How do I read it / convert it as a column of numbers with NaNs for the "NA"s? My code is as below:
data=readtable("Data.csv");
t=table2array(data);
class(t)
ans =
'cell'
0 件のコメント
採用された回答
David Hill
2020 年 4 月 3 日
This works just fine for me.
data=readmatrix('Data.csv');
1 件のコメント
David Hill
2020 年 4 月 3 日
opts = detectImportOptions('Data.csv');
opts.DataLines=[2 Inf];
data=readmatrix('Data.csv',opts);
その他の回答 (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!