Effacer les filtres
Effacer les filtres

Trying to find the min non-zero value of a [925x902] matrix

4 vues (au cours des 30 derniers jours)
Todd Pierce
Todd Pierce le 25 Avr 2022
Commenté : Star Strider le 25 Avr 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?

Réponse acceptée

Star Strider
Star Strider le 25 Avr 2022
Perhaps —
D1.Z = rand(925,902) % Create Test Matrix
D1 = struct with fields:
Z: [925×902 double]
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
Check = 0
MinZ = min(D1.Z(D1.Z~=0),[],'all') % Return Minimum ~= 0
MinZ = 1.2686e-06
.
  6 commentaires
Todd Pierce
Todd Pierce le 25 Avr 2022
Thank you
Star Strider
Star Strider le 25 Avr 2022
My pleasure!
If my Answer helped you solve your problem, please Accept it!
.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by