2013-08-07 61 views
0

我在Matlab中的數據集中有大量的橫截面時間序列數據,我想根據頭部提取數據數組(列),這些數據將從for循環中的另一個數組動態給出。任何人都可以建議如何在Matlab中實現這一點,我曾嘗試下面的代碼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 

這可能嗎? 感謝您的幫助

回答

2

假設cds是一個字符串,它可以被用來作爲一個充滿活力的領域名稱:

cdslist = universe.Bond; 
cdscount = length(universe.Bond); 

spread = struct; 

for i = 1:cdscount 
    cds = cdslist{i}; 
    spread.(cds) = data; 
end 
+0

你甚至可以不用了'cds',只需使用:'傳播(cdslist(。 i))' – Schorsch

+0

你能澄清什麼是數據? –

+0

事情已經作爲橫截面數據的數據集已經存在,我想從安全名稱中提取數據,例如cdslist給出的「X」 –