필터 지우기
필터 지우기

element mean of matrices

조회 수: 5 (최근 30일)
Leela Sai Krishna
Leela Sai Krishna 2019년 3월 18일
댓글: 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에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by