element mean of matrices

3 ビュー (過去 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 Center および File ExchangeResizing and Reshaping Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by