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

조회 수: 4 (최근 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에서 Mathematics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by