How to create price weighted index function?

조회 수: 1 (최근 30일)
de Bord Julien
de Bord Julien 2022년 4월 29일
답변: Jan 2022년 4월 29일
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일
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개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by