Matrix manipulation by function

3 visualizaciones (últimos 30 días)
Lila wagou
Lila wagou el 6 de Abr. de 2017
Comentada: Lila wagou el 7 de Abr. de 2017
Dear all, For a given matrix (square) i need to eliminate some elements (some rows and columns)
A =
35 6 19
3 7 23
31 2 27
I need only the second (not the first and the third) row and column : the eliminated are stocked in a vector
B = (1 3)
So : some function (A, B) :::> the result C = 7
function (A, B) = C
  2 comentarios
KSSV
KSSV el 6 de Abr. de 2017
iwant = A(2,2)
wont it solve the purpose?
Lila wagou
Lila wagou el 6 de Abr. de 2017
Dear KSSV, i need a function for lot of use
A1 =
35 6 19
3 7 23
31 2 27
and
B1 = (1 3)
C1 = 7
or
A2 =
35 6 19 11
3 7 23 44
31 2 27 55
31 2 27 55
and
B2 = (2 3)
C2 =
35 11
31 55

Iniciar sesión para comentar.

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 6 de Abr. de 2017
ii = num2cell([1;1]*setdiff(1:length(A),B(:)'),2);
out = A(ii{:});
  8 comentarios
Andrei Bobrov
Andrei Bobrov el 7 de Abr. de 2017
V_new = V_old;
V_new(V_ord) = V_ins;
Lila wagou
Lila wagou el 7 de Abr. de 2017
Dear Andrei; please how to trait a vector (eliminate the elements stocked in a vector by order)
A = [10 52 33]
B = [3]
ii = num2cell([1]*setdiff(1:length(A),B(:)'),1);
out = A(ii{:});
i get out = 52 so i must get out = 10 52

Iniciar sesión para comentar.

Más respuestas (1)

Fangjun Jiang
Fangjun Jiang el 6 de Abr. de 2017
C=A;
C(B,:)=[];
C(:,B)=[]
  3 comentarios
Jan
Jan el 7 de Abr. de 2017
Yes, hi Fangjun!
Fangjun Jiang
Fangjun Jiang el 7 de Abr. de 2017
Hello, friends!

Iniciar sesión para comentar.

Categorías

Más información sobre Operators and Elementary Operations en Help Center y File Exchange.

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by