필터 지우기
필터 지우기

How do I sort rows and get the average (mean) at the same time?

조회 수: 1 (최근 30일)
Laliguras
Laliguras 2013년 3월 28일
Hi, I have a 5000 X 5 matrix, which I sorted in two group: First group (2500 X 5): 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 (2500 X 5): Pick only those which were not selected in first group. Now I need to get average of those each of picked 5 individual rows (and all columns) to make two sets of 500 X 5 matrices. Thnx in advance.
  댓글 수: 1
Sean de Wolski
Sean de Wolski 2013년 3월 28일
A simple example with: input data, expected results, method of getting to those results is worth 10000 words.

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

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 28일
A=rand(5000,5)
A1=zeros(500,5) % Pre-allocate
A2=A1;
ii=0;
for k=1:10:5000
ii=ii+1
A1(ii,:)=mean(A(k:k+4,:));
A2(ii,:)=mean(A(k+5:k+9,:));
end

카테고리

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