How to sort orders of rows?

조회 수: 1 (최근 30일)
Laliguras
Laliguras 2013년 3월 27일
Hi, I have a matrix, which I need to sort in two group: First group: Pick first 5 rows (and all columns) and leave next five rows and again pick another five, leave next five and so on. Second group: Pick only those which were not selected in first group.
Thanks in advance.
  댓글 수: 1
Laliguras
Laliguras 2013년 3월 28일
As follow-up to previous question, how do I get the average value (mean) of each of those picked 5 rows?
Thanks

댓글을 달려면 로그인하십시오.

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 27일
편집: Azzi Abdelmalek 2013년 3월 27일
Example
A=rand(20,6);
idx=reshape(1:size(A,1),5,[]);
m=size(idx,2);
idx1=idx(:,1:2:end);
idx2=idx(:,2:2:end);
A1=A(idx1(:),:)
A2=A(idx2(:),:)
  댓글 수: 1
Laliguras
Laliguras 2013년 3월 27일
Thanks. It works.

댓글을 달려면 로그인하십시오.

추가 답변 (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