Find function in arrays

18 visualizaciones (últimos 30 días)
Metehan Geçer
Metehan Geçer el 14 de Mayo de 2022
Comentada: Voss el 14 de Mayo de 2022
I am having two matrix. Selected elements in one matrix is present as elements in another matrix. Now i need to find the position of selected elements in the original matrix.
for example
yenidendonguyegirecekler =
-1321.6
-2119.8
-2825.5
-2937.5
-3205.4
-3340.9
-3895.0
-4080.2
-4320.9
fitnesshafiza =
-4080.2
-2937.5
-2825.5
-5749.6
-3205.4
-2119.8
-3340.9
-4320.9
-3895.0
-1321.6

Respuesta aceptada

Voss
Voss el 14 de Mayo de 2022
yenidendonguyegirecekler = [
-1321.6
-2119.8
-2825.5
-2937.5
-3205.4
-3340.9
-3895.0
-4080.2
-4320.9];
fitnesshafiza = [
-4080.2
-2937.5
-2825.5
-5749.6
-3205.4
-2119.8
-3340.9
-4320.9
-3895.0
-1321.6];
To find where the elements of yenidendonguyegirecekler are located in fitnesshafiza:
[~,idx] = ismember(yenidendonguyegirecekler,fitnesshafiza)
idx = 9×1
10 6 3 2 5 7 9 1 8
  2 comentarios
Metehan Geçer
Metehan Geçer el 14 de Mayo de 2022
thx a lot <3
Voss
Voss el 14 de Mayo de 2022
You're welcome!

Iniciar sesión para comentar.

Más respuestas (1)

the cyclist
the cyclist el 14 de Mayo de 2022
You can use the ismember function to find out whether each element of one vector is present in the other, and also the location.
  1 comentario
Metehan Geçer
Metehan Geçer el 14 de Mayo de 2022
for example ismember(A,B) ?

Iniciar sesión para comentar.

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by