Find which matrix row contains average minimum value
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Lumbersnack
am 21 Sep. 2021
Kommentiert: Star Strider
am 21 Sep. 2021
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 Kommentare
the cyclist
am 21 Sep. 2021
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?
Akzeptierte Antwort
Star Strider
am 21 Sep. 2021
One approach —
M = rand(288,365);
AMV = mean(min(M)) % Average Minimum Value
[val,idx] = min(abs(M(:)-AMV)) % Closest Element Value & Linear Index
[row,col] = ind2sub(size(M),idx)
An exact match (exact equality) is highly unlikely.
Experiment to get the result you want.
.
2 Kommentare
Star Strider
am 21 Sep. 2021
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.
.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!