How to create price weighted index function?
1 次查看(过去 30 天)
显示 更早的评论
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
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
2022-4-29
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!