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

 採用された回答

Voss
Voss 2022 年 5 月 14 日

1 投票

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 件のコメント

Metehan Geçer
Metehan Geçer 2022 年 5 月 14 日
thx a lot <3
Voss
Voss 2022 年 5 月 14 日
You're welcome!

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2022 年 5 月 14 日

0 投票

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 件のコメント

Metehan Geçer
Metehan Geçer 2022 年 5 月 14 日
for example ismember(A,B) ?

サインインしてコメントする。

カテゴリ

製品

リリース

R2021a

タグ

質問済み:

2022 年 5 月 14 日

コメント済み:

2022 年 5 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by