MATLAB Answers

pulling array values using min values from separate array

2 views (last 30 days)
Kincaid Gilbert
Kincaid Gilbert on 29 Mar 2021
Edited: KSSV on 29 Mar 2021
basically ill have 2 identical sized arrays with different values
A = [1, 4, 7, 10]
B = [4, 5, 1, 8]
and using the minumium value in B (1) i want to pull the value in the same position as A (7)

Accepted Answer

KSSV
KSSV on 29 Mar 2021
Edited: KSSV on 29 Mar 2021
REad about min function, it also give you the index/ location of the minimum value.
A = [1, 4, 7, 10] ;
B = [4, 5, 1, 8] ;
[val,idx] = min(B)
val = 1
idx = 3
A(idx)
ans = 7

More Answers (0)

Tags

Products


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by