How to create price weighted index function?

1 vue (au cours des 30 derniers jours)
de Bord Julien
de Bord Julien le 29 Avr 2022
Réponse apportée : Jan le 29 Avr 2022
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 commentaire
Jan
Jan le 29 Avr 2022
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.

Connectez-vous pour commenter.

Réponse acceptée

Jan
Jan le 29 Avr 2022
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?

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by