How to match two arrays

3 views (last 30 days)
Yro
Yro on 6 Jan 2021
Answered: KSSV on 6 Jan 2021
Hi, how can I make the match two following arrays? I want to obtain a 29x1 array with the position of the corresponding match.
Tried the following, performing a cell array for each position but I get what I want.
for i = 1:length(PATTERNS_FOR_ERANOS)
DATA_FROM_DAKOTA1{i} = find(POSICIONES_ERANOS(:,1) == PATTERNS_FOR_ERANOS(i,1));
DATA_FROM_DAKOTA2{i} = find(POSICIONES_ERANOS(:,2) == PATTERNS_FOR_ERANOS(i,2));
end
% 87x2 array
POSITIONS = [ ...
31 29
31 30
30 31
29 31
29 30
30 29
31 28
32 28
32 29
...
];
% 29x2 array
PATTERNS_FOR_ERANOS = [...
26 34
28 34
30 34
32 32
34 30
34 28
34 26
33 27
31 27
29 27
...
];
% 29x1 array
DATA_FROM_DAKOTA = [...
1
2
3
4
4
5
7
8
9
3
2
...
];
Thanks in advance.

Answers (1)

KSSV
KSSV on 6 Jan 2021
Read about ismember.

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Tags

Products


Release

R2019a

Community Treasure Hunt

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

Start Hunting!