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

 채택된 답변

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH 2020년 2월 15일

0 개 추천

M=A(ismember(A,B,"rows"),:)

댓글 수: 7

Walter Roberson
Walter Roberson 2020년 2월 15일
Is use of double quotes defined in octave?? I do not know.
The octave experts are elsewhere, at a different resource. Octave is a different programming language and not a suitable question for MATLAB Answers.
Les Beckham
Les Beckham 2020년 2월 15일
Having been forced to use Octave lately due to not having Matlab available currently, I can answer Walter's question.
Double quoted strings are supported in Octave (and seem to be actually preferred as they are used almost exclusively in the documentation for things like fprintf). I still use single quotes for the most part, as that is what I got used to over the years in Matlab. Strings were just introduced when I lost access to Matlab and I never got into the habit of using them.
Walter is right, of course, that asking Octave questions in Matlab Answers isn't really appropriate.
I really do miss Matlab. :(
Walter Roberson
Walter Roberson 2020년 2월 15일
Thanks, Les.
Perhaps you could get a Home license?
Michelle Leung
Michelle Leung 2020년 2월 16일
M=A(ismember(A,B,"rows"),:) works in octave. However, if I also want to compare the column what should I do? I have check M=A(ismember(A,B," column"),:) doesn't work. I am new in using octave and I only have some knowledge on the primary function of creating a matrix and some simple calculations.
Walter Roberson
Walter Roberson 2020년 2월 16일
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 2020년 2월 16일
Yeah, I got it!! Thanks, Roberson
Rik
Rik 2020년 2월 16일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Octave에 대해 자세히 알아보기

질문:

2020년 2월 15일

댓글:

Rik
2020년 2월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by