Read a column as numbers

조회 수: 7 (최근 30일)
Shaoni Nandi
Shaoni Nandi 2020년 4월 3일
댓글: David Hill 2020년 4월 3일
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'

채택된 답변

David Hill
David Hill 2020년 4월 3일
This works just fine for me.
data=readmatrix('Data.csv');
  댓글 수: 1
David Hill
David Hill 2020년 4월 3일
opts = detectImportOptions('Data.csv');
opts.DataLines=[2 Inf];
data=readmatrix('Data.csv',opts);

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

태그

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by