Effacer les filtres
Effacer les filtres

Finding maximum between every two rows of a matrix

1 vue (au cours des 30 derniers jours)
Christopher
Christopher le 17 Nov 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 commentaire
Walter Roberson
Walter Roberson le 17 Nov 2013
Modifié(e) : Walter Roberson le 17 Nov 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 ?

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by