Effacer les filtres
Effacer les filtres

This is Driving Me Crazy: How can I get an index to follow a value, Find the Lowest Value in The Matrix WITHOUT Min and get it to display the Index as the lowest #?

3 vues (au cours des 30 derniers jours)
I know this matrix below might seem kinda weird, but it's to do with a bigger part of a program I'm testing. I need 3 to be referenced as 511, 4 as 818, 7 as 379 and 8 as 812. I've researched hundreds of solutions but I can't get them to work for my situation.
z = 3 4 7 8
511 818 379 812
I want to be able to find the lowest value which I can see here is 379, but I wish to learn without min for understanding of the logic. Counter intuitive I know, but even with min, I cannot get it to display the index vs the value. Really grinds my gears. I'd appreciate the help.

Réponses (1)

Mehmed Saad
Mehmed Saad le 13 Avr 2020
Modifié(e) : Mehmed Saad le 13 Avr 2020
z = [3 4 7 8
511 818 379 812];
when you are using min here, it is comparing rows with each other and giving you min value because it works rowwise
to change it to column type
min(z,[],2)
it will give you
ans =
3
379
if you just want to find the minimum value of 2nd row and it's index
[val,ind] = min(z(2,:))
if you want the corresponding value of 1st Row
z(1,ind)
If you want to the complete column of min
z(:,ind)
In 1 command
z(:,z(2,:)==min(z(2,:)))

Catégories

En savoir plus sur Propagation and Channel Models dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by