필터 지우기
필터 지우기

Getting average of sections of a single row of data

조회 수: 1 (최근 30일)
David
David 2013년 8월 11일
Hi everyone,
I have a single row of data and I am trying to get the mean of a number of different ranges within it i.e t average of the data within the ranges (1:20), (103:130), (229:259), (351:386), (482:512), (612:641). This is my attempt:
Average=mean(Seg1.P_wave(1:20,103:130,229:259,351:386,482:512,612:641));
However, this returns an error stating that the index exceeds the matrix dimensions even though the matrix contains 747 elements. Does anyone know what I am doing wrong?
Thanks

답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 11일
편집: Azzi Abdelmalek 2013년 8월 11일
m1=mean(Seg1.P_wave(1:20));
m2=mean(Seg1.P_wave(103:130));
m3=mean(Seg1.P_wave(229:259));
m4=mean(Seg1.P_wave(351:386));
m5=mean(Seg1.P_wave (482:512));
m6=mean(Seg1.P_wave (612:641));
out=[m1 m2 m3 m4 m5 m6]
%or you want
mean(Seg1.P_wave([1:20,103:130,229:259,351:386,482:512,612:641]));
  댓글 수: 2
David
David 2013년 8월 11일
Hi Azzi. Thanks so much for the help, it works perfectly. Much appreciated.
Azzi Abdelmalek
Azzi Abdelmalek 2013년 8월 11일
David, when the answer helps you have to accept the answer. click on [accept this answer]

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

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by