pulling array values using min values from separate array

1 visualización (últimos 30 días)
Kincaid Gilbert
Kincaid Gilbert el 29 de Mzo. de 2021
Editada: KSSV el 29 de Mzo. de 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)

Respuesta aceptada

KSSV
KSSV el 29 de Mzo. de 2021
Editada: KSSV el 29 de Mzo. de 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

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by