mapping matrix of two vectors

13 visualizaciones (últimos 30 días)
Lama Hamadeh
Lama Hamadeh el 7 de Abr. de 2022
Comentada: Rajiuddin Sk el 1 de Feb. de 2023
Hi,
If I have two vectors and as shown below. Is there a way to create matrix that mapps each row of A with its correspondent in B? In other words, check row by row of both A and B. Row 1 in A has the value of 1 and corresponds to value of 3 in B, then put one, otherwise put zero.
Thanks.

Respuesta aceptada

Davide Masiello
Davide Masiello el 7 de Abr. de 2022
clear,clc
A = [1;2;3;4];
B = [3;1;4;2];
C = A == B'
C = 4×4 logical array
0 1 0 0 0 0 0 1 1 0 0 0 0 0 1 0
  1 comentario
Rajiuddin Sk
Rajiuddin Sk el 1 de Feb. de 2023
Dear Davide,
When the matrix A and B contains symbols, then MATLAB could not find the transformation matrix in above mention method. Can you say how to find the transformation matrix in case of symbolic matrix?

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Multidimensional Arrays en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by