Effacer les filtres
Effacer les filtres

how to find the mean values betwwen 3 matrix?

1 vue (au cours des 30 derniers jours)
aya ben mabrouk
aya ben mabrouk le 10 Juin 2016
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?

Réponse acceptée

Star Strider
Star Strider le 11 Juin 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.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by