Asked by C Zeng
on 5 Jun 2012

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.

*No products are associated with this question.*

Answer by Oleg Komarov
on 5 Jun 2012

Accepted answer

M_new = [M, n]; M_new = sortrows(M_new,6);

See `sortrows()` for details.

Opportunities for recent engineering grads.

## 0 Comments