Read one column from a csv file into MATLAB for calculating
1 view (last 30 days)
Show older comments
Xiaoqing Zhuang
on 22 Mar 2015
Commented: Xiaoqing Zhuang
on 22 Mar 2015
I'd like to read one column from a csv file '2004.csv' which already in the MATLAB path. The column contains 'NaN' value and I want to treat it as empty. The column looks like following:
ArrDelay
NaN
-14
2
14
-6
NaN
11
57
...
-6
NaN
11
57
The variable name is 'ArrDelay' which is the title of the column. The column contains 7009729 records and I'd like to calculate the mean of those records.
How can I make it?
0 Comments
Accepted Answer
Andrei Bobrov
on 22 Mar 2015
out = nanmean(ArrDelay);
or in MATLAB R2015a
out = mean(ArrDelay,'omitnan'));
6 Comments
More Answers (0)
See Also
Categories
Find more on Data Import and Export in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!