element mean of matrices

2 次查看(过去 30 天)
Leela Sai Krishna
Leela Sai Krishna 2019-3-18
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 个评论
madhan ravi
madhan ravi 2019-3-18
illustrate with a short example
Leela Sai Krishna
Leela Sai Krishna 2019-3-18
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];

请先登录,再进行评论。

回答(1 个)

KSSV
KSSV 2019-3-18
编辑:KSSV 2019-3-18
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 个评论
Leela Sai Krishna
Leela Sai Krishna 2019-3-18
编辑:per isakson 2019-3-18
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....

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by