Filter löschen
Filter löschen

display the value from a vector

2 Ansichten (letzte 30 Tage)
Costi Gilca
Costi Gilca am 24 Apr. 2016
Beantwortet: Peta am 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

Akzeptierte Antwort

Peta
Peta am 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)

Weitere Antworten (0)

Kategorien

Mehr zu Matrix Indexing 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!

Translated by