how to form a indexed matrix?

1 visualización (últimos 30 días)
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar el 26 de Nov. de 2018
Comentada: Jan el 26 de Nov. de 2018
Row matrix
A=[0 2 3; 3 2 1; 2 3 1]
Column
B= 2
Index matrix
C=[10 20 50; 60 80 90 ; 20 60 40]
Result expected
i would first select colum As 2
And look for the values of C
Depending on row number from A
D=[0 80 60; 60 80 20; 80 60 20]

Respuesta aceptada

Jan
Jan el 26 de Nov. de 2018
The quetsion is not really clear. With some bold guessing:
A = [1 2 3; 3 2 1; 2 3 1];
B = 2;
C = [10 20 50; 60 80 90 ; 20 60 40];
CB = C(:, B);
D = CB(A)
  3 comentarios
Shubham Mohan Tatpalliwar
Shubham Mohan Tatpalliwar el 26 de Nov. de 2018
Can u suggest me something for zero terms
Jan
Jan el 26 de Nov. de 2018
D = zeros(size(A));
m = (A ~= 0);
D(m) = CB(A(m));

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by