how to match row of two different matrix?

1 view (last 30 days)
I have two matrix, A = [1 2 3; 4 5 6; 7 8 9] and B = [11 12 13]. I want to check, if matrix A has any exact matching row as B? In this case, matrix A doesn't have matching row as B. As a result, i want to add row of B into A such that final A would look like this, A = [1 2 3; 4 5 6; 7 8 9; 11 12 13]. Any idea how to do this?
Thanks in advance.

Accepted Answer

KL
KL on 22 Oct 2017
Edited: KL on 22 Oct 2017
ind = ismember(A,B,'rows');
if (~ind)
A(end+1,:)=B;
end

More Answers (0)

Categories

Find more on Get Started with MATLAB in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!