Octave--compare two matrix

10 vues (au cours des 30 derniers jours)
Michelle Leung
Michelle Leung le 15 Fév 2020
Commenté : Rik le 16 Fév 2020
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

Réponse acceptée

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 15 Fév 2020
M=A(ismember(A,B,"rows"),:)
  7 commentaires
Michelle Leung
Michelle Leung le 16 Fév 2020
Yeah, I got it!! Thanks, Roberson
Rik
Rik le 16 Fév 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Octave dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by