process data from csv file

1 回表示 (過去 30 日間)
Yang
Yang 2014 年 5 月 21 日
コメント済み: Yang 2014 年 5 月 22 日
Hi to all. I am trying to process data from a csv file using matlab. The csv file is like below:
Time, Value
1400660853.068, 614
1400661093.002, 641
1400661332.698, 599
So we have the first line as header and the rest of the first and second columns as data. I am interested in the second column which is the value. I would like to get the column as a matrix(not include the header). How could I do that? I tried to use the textscan command as below:
_clear;
close all;
fid=fopen('C:\Users\yyao\Desktop\Luminance_18.csv');
out=textscan(fid,'%f %d','delimiter',',');
date=out{2}
fclose(fid);_
But then I got date = Empty matrix: 0-by-1
Is there anything wrong with my codes? Thanks so much for helping!

採用された回答

Romain
Romain 2014 年 5 月 21 日
編集済み: Romain 2014 年 5 月 21 日
I suggest you to use the function csvread :
clear;
close all;
out = csvread('C:\Users\yyao\Desktop\Luminance_18.csv',1,0); % start to read at the second row and the first column
value = out(:,2)
  1 件のコメント
Yang
Yang 2014 年 5 月 22 日
Hi,Romain
Thank you so much! It works! It seems that I really have a lot to learn:)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Import and Export についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by