Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

compare two matrices

Asked by Ellen on 23 May 2011

Hi,

I want to compare two matrices for equal values, and I want to know if there is a build-in function to do this. Ihaven't been able to find it in the MATLAB help.

example: A=[1 2 3; 4 5 6; 7 8 9] B=[9 8 7; 6 5 4; 3 2 1] this should return something like result=[0 0 0;0 1 0;0 0 0] so I can see there is an equal number on the same position in both matrices and the position that it is in.

Thanks!

Ellen

0 Comments

Ellen

Products

No products are associated with this question.

1 Answer

Answer by Sean de Wolski on 23 May 2011
Accepted answer
result = A==B;

1 Comment

Ellen on 23 May 2011

Thanks so much.
Sometimes the answer is so simple, you don't think about it

Sean de Wolski

Contact us