how to define specific indexes in a dataset?
이전 댓글 표시
My aim is to define indexes for an in sample and an out of sample test of model fitting.
% define first and last date for calibration
cal_beg_date = '01-01-2010';
cal_end_date = '31-12-2010';
% define first and last date for out-of-sample forecast
for_beg_date = '01-01-2011';
for_end_date = '31-12-2011';
D = ds.Date(:,1);
% define respective indices and period lengths
cal_beg_i = find(D==eval(cal_beg_date));
cal_end_i = find(D==eval(cal_end_date));
for_beg_i = find(D==eval(for_beg_date));
for_end_i = find(D==eval(for_end_date));
cal_period = 1+cal_end_i-cal_beg_i;
for_period = 1+for_end_i-for_beg_i;
I use dataset to create my data in matlab and the adove code returns me an error. Could anyone tell me why a get an error. thanks in advance..
채택된 답변
추가 답변 (1개)
per isakson
2012년 4월 30일
I guess this is not what you want?
>> eval('31-12-2010')
ans =
-1991
카테고리
도움말 센터 및 File Exchange에서 Time Series Objects에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!