Find which matrix row contains average minimum value

조회 수: 1 (최근 30일)
Lumbersnack
Lumbersnack 2021년 9월 21일
댓글: Star Strider 2021년 9월 21일
I have DNI data stored in a 288 x 365 matrix.
I need to find which row contains the average minimum value (all collumns).
Thanks
  댓글 수: 2
the cyclist
the cyclist 2021년 9월 21일
I, for one, don't quite understand what you need. Can you post a small example (e.g. 3x3 matrix), and step through the logic of what you need?
Lumbersnack
Lumbersnack 2021년 9월 21일
Hello, sure. sorry for the confusion.
example:
A = 3 x 4 matrix
I need the mean of all the collumns for each row e.g:
mean(1,:)....mean (2,:)... mean(3,:)
I need a way to find which row index which has the minimum mean.
hope this clears it up.
Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 9월 21일
One approach —
M = rand(288,365);
AMV = mean(min(M)) % Average Minimum Value
AMV = 0.0035
[val,idx] = min(abs(M(:)-AMV)) % Closest Element Value & Linear Index
val = 8.1619e-07
idx = 67083
[row,col] = ind2sub(size(M),idx)
row = 267
col = 233
An exact match (exact equality) is highly unlikely.
Experiment to get the result you want.
.
  댓글 수: 2
Lumbersnack
Lumbersnack 2021년 9월 21일
Thanks for the response. Looking at documentation - I thought mean(A) would return mean of the rows.. is there a way to return mean of Columns for each row?
Star Strider
Star Strider 2021년 9월 21일
My pleasure!
MATLAB uses column-major operations, so mean will take the mean of each column by default. That is how I interpreted:
I need to find which row contains the average minimum value (all collumns).
To take the mean of the rows instead:
AMV = mean(min(M),2) % Average Minimum Value
The rest of the code is unchanged, since it will return both the row and column of the closest match.
.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Delaunay Triangulation에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by