pulling array values using min values from separate array

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)

 Risposta accettata

KSSV
KSSV il 29 Mar 2021
Modificato: KSSV il 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

Più risposte (0)

Prodotti

Release

R2018b

Tag

Richiesto:

il 29 Mar 2021

Modificato:

il 29 Mar 2021

Community Treasure Hunt

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

Start Hunting!

Translated by