element mean of matrices

2 views (last 30 days)
Leela Sai Krishna
Leela Sai Krishna on 18 Mar 2019
Commented: Leela Sai Krishna on 18 Mar 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 Comments
madhan ravi
madhan ravi on 18 Mar 2019
illustrate with a short example
Leela Sai Krishna
Leela Sai Krishna on 18 Mar 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];

Sign in to comment.

Answers (1)

KSSV
KSSV on 18 Mar 2019
Edited: KSSV on 18 Mar 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 Comment
Leela Sai Krishna
Leela Sai Krishna on 18 Mar 2019
Edited: per isakson on 18 Mar 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....

Sign in to comment.

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!