我有一个m
x n
金融时间序列对象(fints),叫做data
。现在,我想通过仅保留相交的日期(系列标题都是唯一的)将其n
的每个系列合并到一个新的 fints 中。
这是我的工作:
headers = fieldnames(data,1); %get the headers.
series = strcat('data.', headers); %list of the series to be merged.
new_fints = merge(series{:},... %merge the series.
'DateSetMethod','Intersection');
但这给了我以下错误:类型为"char"的输入参数的未定义函数"合并"。
我的逗号分隔列表有什么问题?
您需要实际的字段值,例如:
series = struct2cell(data);
如
>> struct2cell(struct('a', 1, 'b', 2, 'c', 3))
ans =
[1]
[2]
[3]
这应该为您提供一个包含所有字段值的单元格数组,并且您的其余代码应按预期工作。