How to combine two matrices to one and sort the rows?

3 次查看(过去 30 天)
Hello, my question is given a matrix M, say 10*5 size and one 10*1 say n. I want to make a new matrix that combine those into one matrix say M_new(10*6 size), the first five columns come from M, and 6th column comes from n.
Afterwards, sort the rows from largest to smallest by the last entry, say the number in n. Is there a good code on this? Thanks.

采纳的回答

Oleg Komarov
Oleg Komarov 2012-6-5
M_new = [M, n];
M_new = sortrows(M_new,6);
See sortrows() for details.
  5 个评论

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by