Trying to find the min non-zero value of a [925x902] matrix
11 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Todd Pierce
am 25 Apr. 2022
Kommentiert: Star Strider
am 25 Apr. 2022
I am trying to find the minimum non-zero value of a [925x902] matrix called D1.Z
i have tried:
min(D1.Z(D1.Z > 0));
D1.Z(D1.Z==0) = nan; then min(min(D1.Z));
Error comes up saying the 'index exceeds the number of array elements (1)'
Anyway around these?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 25 Apr. 2022
Perhaps —
D1.Z = rand(925,902) % Create Test Matrix
D1.Z(randi(numel(D1.Z),1,5)) = 0; % Set Some Elements To Zero
Check = min(D1.Z,[],'all') % Check Matrix To Demonstrate Replacement Effective
MinZ = min(D1.Z(D1.Z~=0),[],'all') % Return Minimum ~= 0
.
6 Kommentare
Star Strider
am 25 Apr. 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.
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!