[英]Dataset in Matlab
I have a large set of cross-sectional time series data in a dataset in Matlab and I want to extract arrays (columns) of data based on the header which will be given dynamically from another array in for loop. 我在Matlab的数据集中有大量的横截面时间序列数据,我想根据标题提取数据的数组(列),这些标题将从for循环中的另一个数组动态给出。 Can anyone suggest how to implement this in Matlab, I have tried the following code 任何人都可以建议如何在Matlab中实现这一点,我已经尝试了以下代码
cdslist = universe.Bond;
cdscount = length(universe.Bond);
for i=1:cdscount
cds = cdslist(i);
% here i want to use this variable cds to dynamically give names to a dataset called spread, for instance spread.cds where cds is changing in the loop.
end
Is this possible ? 这可能吗 ? Thanks for the help 谢谢您的帮助
Assuming cds
is a string, it can be used as a dynamic field name: 假设cds
是一个字符串,它可以用作动态字段名称:
cdslist = universe.Bond;
cdscount = length(universe.Bond);
spread = struct;
for i = 1:cdscount
cds = cdslist{i};
spread.(cds) = data;
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.