Filter löschen
Filter löschen

How to find arrays in matrix

19 Ansichten (letzte 30 Tage)
Moe
Moe am 9 Apr. 2016
Bearbeitet: Azzi Abdelmalek am 9 Apr. 2016
Suppose matrix A is as follows:
A = [1;2;3;4;5];
And matrix B:
B = [1,43,23,45;4,23,64,21;2,43,23,11;3,43,21,88;5,34,23,76;7,31,23,23,88;8,34,65,34];
I want to find the matrix A in matrix B and construct matrix C:
C = [1,43,23,45;2,43,23,11;3,43,21,88;4,23,64,21;5,34,23,76];

Akzeptierte Antwort

Azzi Abdelmalek
Azzi Abdelmalek am 9 Apr. 2016
Bearbeitet: Azzi Abdelmalek am 9 Apr. 2016
Edit
[ii,jj]=ismember(A,B(:,1));
C=B(jj(ii),:)

Weitere Antworten (0)

Kategorien

Mehr zu Data Types finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by