Finding maximum between every two rows of a matrix

1 visualización (últimos 30 días)
Christopher
Christopher el 17 de Nov. de 2013
Editada: Walter Roberson el 17 de Nov. de 2013
Hello everyone,
I have a matrix that I am trying to break up based on maximums. I will explain this with a simplified example. So I have a matrix as follows:
A=[1 2 3;6 7 8;4 5 6;1 2 3;4 5 6;1 2 3];
I am trying to create a new matrix based off of this matrix as follows. I want to include the first and last row UN-changed in the new matrix, then find the maximum between every two rows of column 2 and return that row to the new matrix. So the new matrix would be
newA=[1 2 3;6 7 8;4 5 6;1 2 3]
So the first row in newA is [1 2 3] because it is left unchanged. Row 2 is [6 7 8] because between row 2 and 3, row 2 has the larger value in column 2. Row 3 is [4 5 6] because between row 4 and 5, row 5 has the larger value in column 2. Row 4 is [1 2 3] because it is left unchanged.
Any help would be great. Thanks!
  1 comentario
Walter Roberson
Walter Roberson el 17 de Nov. de 2013
Editada: Walter Roberson el 17 de Nov. de 2013
This looks like it should be similar to your earlier question http://www.mathworks.co.uk/matlabcentral/answers/106342-finding-maximums-in-matrix-columns . I don't see the difference at the moment ?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices 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