全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
6153 3
2008-09-16

请问使用matlab2008a的ascii2fts函数读取时间序列,出现下述提示,什么原因?如何解决??谢谢!!

??? Attempted to access headr(1); index out of bounds because numel(headr)=0.

Error in ==> ascii2fts at 302
            if ~strcmp(headr(1), ' ')

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2008-9-17 09:32:00
没人回答
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2008-9-17 11:22:00

你的时间文件没有列名吧

以下是matlab里的帮助:

ascii2fts

Create financial time series object from ASCII data file

Syntax

tsobj = ascii2fts(filename, descrow, colheadrow, skiprows) tsobj = ascii2fts(filename, timedata, descrow, colheadrow, skiprows) 

Arguments

filename

ASCII data file

descrow

(Optional) Row number in the data file that contains the description to be used for the description field of the financial time series object

colheadrow

(Optional) Row number that has the column headers/names

skiprows

(Optional) Scalar or vector of row numbers to be skipped in the data file

timedata

Set to 'T' if time-of-day data is present in the ASCII data file or to 'NT' if no time-of-day data is present.

Description

tsobj = ascii2fts(filename, descrow, colheadrow, skiprows) creates a financial time series object tsobj from the ASCII file named filename. This form of the function can only read a data file without time-of-day information and create a financial time series object without time information. If time information is present in the ASCII file, an error message appears.

The general format of the text data file is

  • Can contain header text lines.

  • Can contain column header information. The column header information must immediately precede the data series columns unless skiprows is specified.

  • Leftmost column must be the date column.

  • Dates must be in a valid date string format:

    • 'ddmmmyy' or 'ddmmmyyyy'

    • 'mm/dd/yy' or 'mm/dd/yyyy'

    • 'dd-mmm-yy' or 'dd-mmm-yyyy'

    • 'mmm.dd,yy' or 'mmm.dd,yyyy'

  • Each column must be separated either by spaces or a tab.

tsobj = ascii2fts(filename, timedata, descrow, colheadrow, skiprows) creates a financial time series object containing time-of-day data. Set timedata to 'T' to create a financial time series object containing time-of-day data.

Examples

Example 1. If your data file contains no description or column header rows,

1/3/95 36.75 36.9063 36.6563 36.875 1167900 1/4/95 37 37.2813 36.625 37.1563 1994700 ... 

you can create a financial time series object from it with the simplest form of the ascii2fts function:

myinc = ascii2fts('my_inc.dat'); myinc = desc: my_inc.dat freq: Unknown (0) 'dates: (2)' 'series1: (2)' 'series2: (2)' 'series3: (2)'... '03-Jan-1995' [ 36.7500] [ 36.9063] [ 36.6563] '04-Jan-1995' [ 37] [ 37.2813] [ 36.6250] 

Example 2: If your data file contains description and column header information with the data series immediately following the column header row,

International Business Machines Corporation (IBM) Daily prices (1/3/95 to 4/5/99) DATE OPEN HIGH LOW CLOSE VOLUME 1/3/95 36.75 36.9063 36.6563 36.875 1167900 1/4/95 37 37.2813 36.625 37.1563 1994700 ... 

you must specify the row numbers containing the description and column headers:

ibm = ascii2fts('ibm9599.dat', 1, 3); ibm = desc: International Business Machines Corporation (IBM) freq: Unknown (0) 'dates: (2)' 'OPEN: (2)' 'HIGH: (2)' 'LOW: (2)' ... '03-Jan-1995' [ 36.7500] [ 36.9063] [ 36.6563] '04-Jan-1995' [ 37] [ 37.2813] [ 36.6250] 

Example 3: If your data file contains rows between the column headers and the data series, for example,

Staples, Inc. (SPLS) Daily prices DATE OPEN HIGH LOW CLOSE VOLUME Starting date: 04/08/1996 Ending date: 04/07/1999 4/8/96 19.50 19.75 19.25 19.375 548500 4/9/96 19.75 20.125 19.375 20 1135900 ... 

you need to indicate to ascii2fts the rows in the file that must be skipped. Assume that you have called the data file containing the Staples data above staples.dat. The command

spls = ascii2fts('staples.dat', 1, 3, [4 5]); 

indicates that the fourth and fifth rows in the file should be skipped in creating the financial time series object:

spls = desc: Staples, Inc. (SPLS) freq: Unknown (0) 'dates: (2)' 'OPEN: (2)' 'HIGH: (2)' 'LOW: (2)' '08-Apr-1996' [ 19.5000] [ 19.7500] [19.2500] '09-Apr-1996' [ 19.7500] [ 20.1250] [19.3750] 

Example 4: Create a financial time series object containing time-of-day information.

First create a data file with time information:

dates = ['01-Jan-2001';'01-Jan-2001'; '02-Jan-2001'; ... '02-Jan-2001'; '03-Jan-2001';'03-Jan-2001']; times = ['11:00';'12:00';'11:00';'12:00';'11:00';'12:00']; serial_dates_times = [datenum(dates), datenum(times)]; data = round(10*rand(6,2)); stat = fts2ascii('myfts_file2.txt',serial_dates_times,data, ... {'dates';'times';'Data1';'Data2'},'My FTS with Time'); 

Now read the data file back and create a financial time series object:

MyFts = ascii2fts('myfts_file2.txt','t',1,2,1) MyFts = desc: My FTS with Time freq: Unknown (0) 'dates: (6)' 'times: (6)' 'Data1: (6)' 'Data2: (6)' '01-Jan-2001' '11:00' [ 9] [ 4] ' " ' '12:00' [ 7] [ 9] '02-Jan-2001' '11:00' [ 2] [ 1] ' " ' '12:00' [ 4] [ 4] '03-Jan-2001' '11:00' [ 9] [ 8] ' " ' '12:00' [ 9] [ 0] 你有序列号码吗,如果有借我用一下,请发到邮箱fc13240@163.com
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

2015-1-11 21:37:26
好像是数组访问越界。 检查一下程序。
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群