Use data from matlab function "tomonthly"

조회 수: 2 (최근 30일)
Jan Morawietz
Jan Morawietz 2014년 12월 11일
편집: per isakson 2014년 12월 12일
Taking the offilcial mathworks example: How to convert to monthly data
load predict_ret_data.mat
x0 = fints(expdates, expdata, {'Metric'}, 'w', 'Index')
tomonthly(x0)
Can someone please tell how I can extract the data for calcuations, e.g. take only the monthly prices and convert into a vector?
Best Jan

채택된 답변

per isakson
per isakson 2014년 12월 12일
편집: per isakson 2014년 12월 12일
Old memories awake, a long time ago we had to use getfield and setfield with structs
>> s.f=17;
>> getfield( s, 'f' )
ans =
17
Try
xm = tomonthly(x0);
val = getfield( xm, 'Metric' );
val'
returns
ans =
Columns 1 through 8
108.4028 118.2912 131.2854 78.5738 72.9190 49.4032 53.9584 56.4897
Columns 9 through 12
46.5143 36.9287 36.9495 28.5665
However
val = xm.Metric;
val
returns
ans =
desc: TOMONTHLY: Index
freq: Monthly (3)
'dates: (12)' 'Metric: (12)'
'29-Jan-1999' [ 108.4028]
'26-Feb-1999' [ 118.2912]
'31-Mar-1999' [ 131.2854]
'30-Apr-1999' [ 78.5738]
'28-May-1999' [ 72.9190]
'30-Jun-1999' [ 49.4032]
'30-Jul-1999' [ 53.9584]
'31-Aug-1999' [ 56.4897]
'30-Sep-1999' [ 46.5143]
'29-Oct-1999' [ 36.9287]
'30-Nov-1999' [ 36.9495]
'31-Dec-1999' [ 28.5665]
>>
And I had to browse several pages to find out.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by