Help on creating a comma-separated list of financial time series objects

I'm trying to create a list of comma-separated financial time series objects (fints), in order to pass it to the financial toolbox function merge(). I currently have a 500x1 cell array, where each cell contains one fints. Now I'd like to merge the closing prices (of each fints) into a final fints while keeping only the data points whose dates intersect. I've tried numerous ways to do that, but in the end all of them resulted in errors which said that somehing's wrong with the comma-separated list. This is my latest (ugly and non-working) attempt:
for i = 1:length(cellarray),
list{i} = strcat('cellarray{',num2str(i),'}.Close');
end
finalFints = merge(list{:},'DateSetMethod','Intersection');
Any help would be greatly appreciated...

답변 (1개)

T = {cellarray.Close};
finalFints = merge(T{:}, 'DataSetMethod', 'Intersection');
You might need
T = cellfun( @(F) F.close, cellarray, 'Uniform', 0);
finalFints = merge(T{:}, 'DataSetMethod', 'Intersection');

댓글 수: 1

dave
dave 2013년 12월 14일
편집: dave 2013년 12월 14일
Thanks Walter, your second solution gives me the desired comma-separated list. However, due to the fact that the closing price series all have the same names , the merge () function obviously just collapses all of them into a single series. But since I would like to have all of the series in the final fints, I'm now trying to give each of the closing price series a unique name using the function chfield (). Is there a way to make your code solution work also with different series names?

이 질문은 마감되었습니다.

질문:

2013년 12월 14일

마감:

2021년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by