Info

この質問は閉じられています。 編集または回答するには再度開いてください。

financial time series sum

1 回表示 (過去 30 日間)
Chiara Marcangeli
Chiara Marcangeli 2017 年 1 月 20 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Hi we have a similar financial series:
'dates: (20)' 'Apple: (20)' 'Jpm: (20)' 'Cat: (20)' 'Aa: (20)'
'04-Mar-1994' [ 3830.90] [ 3868.04] [ 3800.50] [ 3832.30]
'07-Mar-1994' [ 3851.72] [ 3882.40] [ 3824.71] [ 3856.22]
'08-Mar-1994' [ 3858.48] [ 3881.55] [ 3822.45] [ 3851.72]
'09-Mar-1994' [ 3853.97] [ 3874.52] [ 3817.95] [ 3853.41]
how can we sum the 'Apple' with the 'Cat' values for each date? we tried to use plus (+) but didn't work out, the error was:
Error using + (line 42) FINTS objects are not compatible (identical).
Thank you

回答 (1 件)

Maitreyee Mordekar
Maitreyee Mordekar 2017 年 1 月 23 日
Hi Chiara,
The error is caused because you need to convert the data to matrix format before you can add the two values as given in the following reference link- http://in.mathworks.com/help/finance/working-with-financial-time-series-objects.html
To add the two columns for each of the date values, you will have to use 'fts2mat' function- http://in.mathworks.com/help/finance/fts2mat.html
The following code snippet will help you sum the variables from 'Apple' with the 'Cat' values for each date-
SumVal= fts2mat(myfts.Apple) + fts2mat(myfts.Cat);
Here, I assume that the name of your financial series in 'myfts'. 'SumVal' will store the value of sum of the two columns.

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by