Clear Filters
Clear Filters

how to find the mean values betwwen 3 matrix?

1 view (last 30 days)
Hello everyone, I have three matrix A, B and C (size 1000*1000), I want to generate a new matrix D that contain average values between A, B and C. For more clarification, there is a little example :
A= [1,2,8; 5,6,7;7,5,8]
B=[0.2,5,1; 0.55,8,4;55,7,9] =====> D=[0.2,2,1;0.55,6,4;0.6,5,1]
C=[1,5,7; 2,6,8;0.6,7,1]
Please, How can I do it?

Accepted Answer

Star Strider
Star Strider on 11 Jun 2016
This works:
A= [1,2,8; 5,6,7;7,5,8];
B=[0.2,5,1; 0.55,8,4;55,7,9];
C=[1,5,7; 2,6,8;0.6,7,1];
Cat = cat(3, A, B, C);
D = min(Cat, [], 3)
D =
0.2 2 1
0.55 6 4
0.6 5 1
Your desired result is not the average or mean values, but the minimum or min values.
If you actually want the average or mean values, change the ‘D’ assignment to:
D = mean(Cat, 3)
I separated out the concatenated matrices, ‘Cat’ assignment so you could see how the code works. You can of course combine them ionto one statement.

More Answers (0)

Categories

Find more on Creating and Concatenating Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!