Moving Std Dev for 20 periods

I Have a (3000,100) Matrix containing the Returns of 3,000 companies for 100 periods (there are some nan values), and i'd like to compute volatility (std dev) for each company, for 20 periods. This is, first the average from period 1 to period 20 for company i, next the average from period 2 to period 21 and so on for each company.
Thanks for the support

回答 (1 件)

Chunru
Chunru 2022 年 8 月 22 日

0 投票

a = randn(3000, 100);
b = movstd(a, 20, 0, 2, 'omitnan');

カテゴリ

ヘルプ センター および File ExchangeFinancial Toolbox についてさらに検索

製品

リリース

R2021a

質問済み:

2022 年 8 月 22 日

回答済み:

2022 年 8 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by