element mean of matrices

2 visualizaciones (últimos 30 días)
Leela Sai Krishna
Leela Sai Krishna el 18 de Mzo. de 2019
Comentada: Leela Sai Krishna el 18 de Mzo. de 2019
I have 5 matrices of 20*20 size, i want to calculate mean of each element. But i am trying to ommit the least values like <15% from Maximum of each element (i.e if there is any value <15%of maximum on each element of 5 matrices). Plz suggest the process and code
  2 comentarios
madhan ravi
madhan ravi el 18 de Mzo. de 2019
illustrate with a short example
Leela Sai Krishna
Leela Sai Krishna el 18 de Mzo. de 2019
for example i have a code like following
a=randi(100,1,10); %1*10 matrix with range upto 100
b=rand(100,1,10); %1*10 matrix
c=rand(100,1,10); %1*10 matrix
A=[a;b;c]; % out matrix is 3*10 matrix
A_max=max(A); %output will be 1*10 matrix
i want to apply the condition like if the value on each column shold not be <15% of maximum value on that column.
for eample i have a matrix as follows
A=[100,90,65;
11,68,98;
58,25,8];
i want mean of this after applying the condition(omit <15% of maximum value).
the required output should be like
Out=[79,61,81.5];

Iniciar sesión para comentar.

Respuestas (1)

KSSV
KSSV el 18 de Mzo. de 2019
Editada: KSSV el 18 de Mzo. de 2019
A = rand(5,5,7) ; % some random data for demo
iwant = zeros(7,1) ; % initialize the required
for i = 1:7
Ai = A(:,:,i) ; % the present mtrix
A_max = max(Ai(:)) ; % get max of the matrix
idx = Ai<15/100*A_max ; % get indices less then 15% of the max
iwant(i) = mean(Ai(idx)) ; % get mean
end
You may do this without defining those many variables. For your understanding I have used the extra variables.
  1 comentario
Leela Sai Krishna
Leela Sai Krishna el 18 de Mzo. de 2019
Editada: per isakson el 18 de Mzo. de 2019
Thanks for your response
For suppose i have a data like following
val(:,:,1) =
89
75
53
49
61
11
57
14
46
14
val(:,:,2) =
11
84
99
11
83
10
31
46
45
34
val(:,:,3) =
78
85
35
83
91
90
74
60
70
17
then i want mean of 1st element be like (89+78)/2 after omitting <15% of max value. and same for remaining elements also.
If there is no value less than 15% of the maximum then the mean should have to calculate as (N1+N2+N3)/3.
(output value not like (89+11+78)/3 or (89+78)/3) for 1st element. ).
your response is helpful for me, Thanks....

Iniciar sesión para comentar.

Categorías

Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by