Azzera filtri
Azzera filtri

display the value from a vector

2 visualizzazioni (ultimi 30 giorni)
Costi Gilca
Costi Gilca il 24 Apr 2016
Risposto: Peta il 24 Apr 2016
Hello,
I have 2 vectors like this: a=[ 95 120 115 132 ...] b=[ 300 250 375 320 ...] Each set of values are associated so when I use minimum for the elements of first vector I want to display myself the value associated from the second vector: For example: if the minimum value in vector a is 95 I want to show me the 300 value, if the minimum is 115 I want to display 375 etc. Could anybody help me, please? Thank you

Risposta accettata

Peta
Peta il 24 Apr 2016
This is what I usually do:
% Find the index of the minimum value in a and store it in the variable pos.
[~,pos] = min(a);
% Use pos to get the corresponding value from b:
b(pos)

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by