How can i take specific values from a matrix and put them into another matrix?

2 次查看(过去 30 天)
I have a 2170x2 matrix: the first column is filled with my values and the second one goes from 1 to 12 over and over again (1 to 12 representing each month of the year).
I need to regroup the values corresponding to each month together ( all the values from the first column that have the same number in the second column) but I can't figure it out.

采纳的回答

Matt J
Matt J 2018-11-29
编辑:Matt J 2018-11-29
Let's say your matrix is A,
Matrices=splitapply(@(z){z},A,A(:,2))

更多回答(1 个)

Matt J
Matt J 2018-11-29
编辑:Matt J 2018-11-29
sortrows(yourMatrix,2)
  1 个评论
Samy Ben Thabet
Samy Ben Thabet 2018-11-29
That worked to separate everything but they are all still in one matrix. Is there a way to separate them all into different ones? (all the ones in one matrix, the twos in another matrix...)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by