How to create price weighted index function?

I'm looking to calculate the following price weighted function using the average price data AvgPrice2019. It just results in NaN. Can someone help?
I still keep getting NaN. Do you know why?

1 件のコメント

Jan
Jan 2022 年 4 月 29 日
Typing an answer would be easier, if you post the code as text, not as screenshot. Then the readers can copy&paste it to show a modification.

サインインしてコメントする。

 採用された回答

Jan
Jan 2022 年 4 月 29 日

0 投票

Start with using Matlab methods instead of the loops:
avg = AvgPrice2019;
meanAavg = sum(avg);
pweight = avg / meanAvg;
If this replies NaNs only, a value in avg is infinite:
avg(~isfinite(avg))
What do you see?

その他の回答 (0 件)

カテゴリ

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

質問済み:

2022 年 4 月 29 日

回答済み:

Jan
2022 年 4 月 29 日

Community Treasure Hunt

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

Start Hunting!

Translated by