Borrar filtros
Borrar filtros

how to swap this matrix

2 visualizaciones (últimos 30 días)
Anusha
Anusha el 17 de Oct. de 2013
Comentada: Anusha el 17 de Oct. de 2013
Matrix
A=
9
3
4
5
6
7
find the min value in the matrix, and take that position
and swap this matrix
Z=
5
3
8
1
4
7
swap that min value Position in a A matrix and the first value in Z matrix

Respuesta aceptada

Andrei Bobrov
Andrei Bobrov el 17 de Oct. de 2013
Editada: Andrei Bobrov el 17 de Oct. de 2013
[v,ia] = min(A);
A(ia) = Z(1);
Z(1) = v;
ADD
[~,ia] = min(A);
Z([ia,1]) = Z([1,ia]);
  3 comentarios
Andrei Bobrov
Andrei Bobrov el 17 de Oct. de 2013
corrected, see ADD part in answer.
Anusha
Anusha el 17 de Oct. de 2013
yes thank you

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Logical 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