I have a simulation in Matlab that produces a 3D matrix (date, start point, trial) of size <103x11x6 double>. It is a simulation that returns a simulated interest rate over 103 time steps for 11 different starting values. This is repeated 6 times.
I wish to simply create a new matrix that returns the average of all these trials. i.e. a single time series for each starting point where the time series is the average interest rate of all the trials for each time point.
Many thanks for any help.
I have a simulation in Matlab that produces a 3D matrix (date, start point,
Share
If the matrix is M, then
then
Ahas one dimensiondateand each value ofAis the average over the 11×6 matrix at that date.mean(M,3)is a 2-d matrix, which you can then take the mean of.Interestingly,
will give you the same result. M(:,:) will collapse M down to 2 dimensions, with the first one preserved and all the later dimensions (only 2nd and 3rd in your case) collapsed to a single dimension.