Use data from matlab function "tomonthly"
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Jan Morawietz
le 11 Déc 2014
Modifié(e) : per isakson
le 12 Déc 2014
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
0 commentaires
Réponse acceptée
per isakson
le 12 Déc 2014
Modifié(e) : per isakson
le 12 Déc 2014
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!