Clear Filters
Clear Filters

display the value from a vector

2 views (last 30 days)
Costi Gilca
Costi Gilca on 24 Apr 2016
Answered: Peta on 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

Accepted Answer

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

More Answers (0)

Community Treasure Hunt

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

Start Hunting!