フィルターのクリア

Time serie import from csv

19 ビュー (過去 30 日間)
Agnete
Agnete 2013 年 10 月 4 日
回答済み: Andualem 2024 年 2 月 22 日
I need help on import of a time series to matlab. The time series has been converted to csv (number formats gets the dilimanation ""?!!). I have tried Import Data Wizard to import the csv file, but it resulted in one collected column.
Then I tried to make a script. Currently I get this error message:
Error using textscan Delimiter must be a string.
Error in importfile (line 6) A=textscan(fid,'%s %f %f %f %f %f %f %f %f %f %f','HEADERLINES',1 ,'Delimiter', {',' ,'"'},'CollectOutput',1,'HEADERLINES',1);
My code is: function [data,time,ts1]=importfile(NAMgaug) clear all NAM='Nam_rain_2005-2011_6.csv'; fid=fopen(NAM,'r'); A=textscan(fid,'%s %f %f %f %f %f %f %f %f %f %f','HEADERLINES',1 ,'Delimiter', {',' ,'"'},'CollectOutput',1,'HEADERLINES',1); fclose(fid); time=datenum(A(end:1)); data=A(end:2); ts1=timeseries(data,datestr(time)); end
Any heads-up is greatly appreciated
By the way I use Matlab R2012a
  2 件のコメント
Cedric
Cedric 2013 年 10 月 4 日
Why do you need the conversion to CSV?
Agnete
Agnete 2013 年 10 月 6 日
I thought matlab could not read excel formats. Thanks so much for the reply.

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

採用された回答

Cedric
Cedric 2013 年 10 月 4 日
編集済み: Cedric 2013 年 10 月 4 日
I'd personally read data directly from the XLS file..
[num,txt] = xlsread( 'Nam_rain_2005-2011_6.xls' ) ;
dates = datenum( txt(2:end) ) ;
columnCodes = num(1,:) ;
data = num(2:end,:) ;
which avoids the conversion to CSV and the need for building a TEXTSCAN-based parser.

その他の回答 (1 件)

Andualem
Andualem 2024 年 2 月 22 日
i have csv data for pm2.5 and want work plot

カテゴリ

Help Center および File ExchangeText Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by