필터 지우기
필터 지우기

mean according to another column

조회 수: 1 (최근 30일)
Thar
Thar 2015년 1월 16일
댓글: Thar 2015년 1월 16일
Hi all!! I need your help please!
My data are in 4 columns:
5,11550634065452 5,68000000000000 2,89500000000000e+18 0,000277777777777821
5,11371667045788 5,68027777777778 4,28850000000000e+18 0,000277777777778709
5,11237469650691 5,68055555555556 3,99960000000000e+18 0,000277777777776933
5,11058681295688 5,68083333333333 3,56330000000000e+18 0,000277777777777821
4,22865065482816 5,89750000000000 2,74900000000000e+18 0,216666666666667
4,22683293766465 5,89805555555556 3,82680000000000e+18 0,000555555555555642
4,22531743417035 5,89861111111111 3,05860000000000e+18 0,000555555555555642
4,22380486438042 5,89916666666667 3,72440000000000e+18 0,000555555555555642
4,22229371155370 5,89944444444445 3,42520000000000e+18 0,277777777777821
4,22078125510264 5,90000000000000 2,90090000000000e+18 0,000555555555555642
4,21927232883456 5,90027777777778 2,72760000000000e+18 0,000277777777776933
4,21806586681390 5,90083333333333 3,59180000000000e+18 0,000555555555555642
4,21655652713407 5,90138888888889 4,65340000000000e+18 0,000555555555555642
I'd like to find mean values from columns 1:3, but not from all lines. The 4th column has some lines where the number is >0.01, like the lines 5 & 9. So, I want to find the mean from lines 1-4, 5-8, and 9 until the number from 4th column is >0.01 and so on, until line 4878. (the step is not stable).
What can i do?
Thank you!

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2015년 1월 16일
If your matrix is named a
idx=a(:,4)<=0.01
out=mean(a(idx,1:3),2)
  댓글 수: 2
Thar
Thar 2015년 1월 16일
The result out has more lines from the first data. It not find mean values from lines 1:4 then 5:8 and so on. Can i do anything else?
Thank you!
Thar
Thar 2015년 1월 16일
my script is:
G=[X,X1,Y]; %airmass, time, SCD
for k=1:4828
G(k+1,4)=G(k+1,2)-G(k,2); %dif_time
end
idx=G(:,4)<=0.01;
out=mean(G(idx,1:3),2);

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

카테고리

Help CenterFile Exchange에서 Dictionaries에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by