extracting values above 0 in an array and putting them in a new array
Afficher commentaires plus anciens

how can i get a 1x5 array by taking values of non-zero? (e.g. taking the first column and taking the first minimum value greater than zero)?
1 commentaire
Walter Roberson
le 3 Juil 2020
Question: for column 4, should the output be 1.6807 as the "first" mininum value that is greater than 0? Or should it be 1.6054 because that is the minimum non-zero value in the row? Or should it be 3.8141 because that is the first non-zero value after the 0 ?
Réponse acceptée
Plus de réponses (1)
madhan ravi
le 3 Juil 2020
matrix(matrix <= 0) = inf;
Wanted = min(matrix)
6 commentaires
Hatim Altarteer
le 3 Juil 2020
madhan ravi
le 3 Juil 2020
Modifié(e) : madhan ravi
le 3 Juil 2020
Huh?
>> matrix = [.1, -1;...
0, .01;...
.03, 0]
matrix(matrix <= 0) = inf
Wanted = min(matrix)
matrix =
0.1000 -1.0000
0 0.0100
0.0300 0
matrix =
0.1000 Inf
Inf 0.0100
0.0300 Inf
Wanted =
0.0300 0.0100
KALYAN ACHARJYA
le 3 Juil 2020
"extracting values above 0 in an array and putting them in a new array"
then I am not getting the question till yet.
madhan ravi
le 3 Juil 2020
Well you need to read the content as well , not the question alone.
Hatim Altarteer
le 3 Juil 2020
Modifié(e) : Hatim Altarteer
le 3 Juil 2020
madhan ravi
le 3 Juil 2020
Hatim you need to accept dipak’s answer because he was first before me. I was typing the answer in my phone so didn’t realise there was an answer already.
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!