Azzera filtri
Azzera filtri

how to find the mean values betwwen 3 matrix?

1 visualizzazione (ultimi 30 giorni)
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?

Risposta accettata

Star Strider
Star Strider il 11 Giu 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.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by