楼主: llllmnmn
6209 3

[求助]请问使用matlab2008a读取时间序列,出现下述提示,如何解决?? [推广有奖]

  • 0关注
  • 0粉丝

VIP

已卖:185份资源

讲师

97%

还不是VIP/贵宾

-

威望
1
论坛币
19114 个
通用积分
7.9807
学术水平
1 点
热心指数
1 点
信用等级
0 点
经验
10276 点
帖子
321
精华
0
在线时间
488 小时
注册时间
2005-6-4
最后登录
2025-7-24

楼主
llllmnmn 发表于 2008-9-16 17:04:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币

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

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

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

二维码

扫码加我 拉你入群

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

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

关键词:matlab2008a MATLAB matla atlab 时间序列 时间 序列 提示 下述

沙发
llllmnmn 发表于 2008-9-17 09:32:00
没人回答

藤椅
fc013 发表于 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

板凳
matlab-007 发表于 2015-1-11 21:37:26
好像是数组访问越界。 检查一下程序。

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-5 17:56