MATLAB Answers

Octave--compare two matrix

20 views (last 30 days)
How can I insert the row of matrix A into matrix M if the whole row of matrix A and matrix B are the same?
There is the example
>> A = [1 2; 3 4]
A =
1 2
3 4
>> B = [1 2; 3 6]
B =
1 2
3 6
M =
1 2

  0 Comments

Sign in to comment.

Accepted Answer

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH on 15 Feb 2020
M=A(ismember(A,B,"rows"),:)

  7 Comments

Show 4 older comments
Walter Roberson
Walter Roberson on 16 Feb 2020
Transpose the data you send into ismember so that the column you want to compare becomes a row for the purpose of comparing.
Michelle Leung
Michelle Leung on 16 Feb 2020
Yeah, I got it!! Thanks, Roberson
Rik
Rik on 16 Feb 2020
Note that Matlab and Octave are sufficiently similar that basic tutorials will work for both. There are several places you can find the most important syntax differences. One of them you encountered here: single and double quotes are interchangeable in Octave, in Matlab they are not.

Sign in to comment.

More Answers (0)


Translated by