How to get average of certain cells in a three dimensional table?
4 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
回答(1 个)
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
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!