フィルターのクリア

How to get average of certain cells in a three dimensional table?

2 ビュー (過去 30 日間)
JBA Miller
JBA Miller 2021 年 3 月 19 日
回答済み: David Hill 2021 年 3 月 19 日
Hi!
I have a 61x2x1000 double which gives me the results of 1000 simulations for stock prices of 61 consecutive months. This is for two different stocks, why the third dimension here is 2.
How do I get to the average stock price of one stock for each month? Or let's say the average for every second month price for stock 1 of all the 1000 trials?
Thanks!

回答 (1 件)

David Hill
David Hill 2021 年 3 月 19 日
Average price of stock each month.
stockA=zeros(1,61);
stockB=zeros(1,61);
for k=1:61
stockA(k)=mean(yourMatrix(k,1,:));
stockB(k)=mean(yourMatrix(k,2,:));
end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

製品


リリース

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by