Compare 2 Matrixs Different Dimension With For

3 visualizaciones (últimos 30 días)
Aldo Milleano
Aldo Milleano el 16 de Ag. de 2022
Movida: KSSV el 16 de Ag. de 2022
I have 2 matrixs with different dimension.
A = [1 1 1 1 2 4 2 3 2 1];
B = [4 1 3 1 2];
The size of matrixs A is 10x1, B is 5x1, i want make matrix C with size (10x5). C is a compare matrix between A and B. If A and B are same the result is 0 and if A and B not same the result is 1.
Example:
C =[1 0 1 0 1;
1 0 1 0 1;
1 0 1 0 1;
1 0 1 0 1;
1 1 1 1 0;
0 1 1 1 1;
1 1 1 1 0;
1 1 0 1 1;
1 1 1 1 0;
1 0 1 0 1; ]

Respuesta aceptada

KSSV
KSSV el 16 de Ag. de 2022
A = [1 1 1 1 2 4 2 3 2 1];
B = [4 1 3 1 2];
idx = A'==B
idx = 10×5 logical array
0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 0 1 0 0 0 0 0 1 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0 1 0 1 0 1 0
  1 comentario
Aldo Milleano
Aldo Milleano el 16 de Ag. de 2022
Movida: KSSV el 16 de Ag. de 2022
Thank you so much sir, it works

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by