Data filtering one-second averages

조회 수: 6 (최근 30일)
Chad Wiggins
Chad Wiggins 2016년 3월 28일
댓글: Chad Wiggins 2016년 3월 30일
I have a data set that is collected at about 6.5hz. In the processing of the data, I put the data into Excel and just do a 3 second running average for the entire data set to smooth out the data. Next I would like for a Matlab program to just pick one point per second. I was thinking it could be the first data point each second. For example, if the times for the first second are 1.088, 1.242. 1.398, 1.553, 1.706, and 1.863, I would just want to pull the row of data at 1.088 and output it into a new a variable.
What would be the best way to go about doing this. If there's code to automate the 3 second running average (about 20 lines in excel), that'd be awesome too. Thanks!
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2016년 3월 28일
The question is not clear, can you illustrate with an example?
Chad Wiggins
Chad Wiggins 2016년 3월 29일
Pretty much, I just want to pull one line of data each second. In the case above, I would want it to have the line where time = 0, 1.088, 2.020, 3.103, 4.033, and 5.12
This will just downsample the data and make it easier to work with and do different analysis with.
Help a little?

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

채택된 답변

MHN
MHN 2016년 3월 30일
편집: MHN 2016년 3월 30일
Load your data in a matrix which the name is Data, then
EndSecond = 3;
NewData = zeros(EndSecond+1,5);
for i = 0:EndSecond
ind = find(Data>=i & Data<i+1,1,'first');
NewData(i+1,:) = Data(ind, :);
end
  댓글 수: 2
Chad Wiggins
Chad Wiggins 2016년 3월 30일
Thank you. This works. Only issue is that it throws an error (Improper assignment with rectangular empty matrix.) after the line with NewData(i+1,:) = Data(ind, :);
The NewData variable looks to be correct. Will this prevent me from putting any other commands after this though?
Chad Wiggins
Chad Wiggins 2016년 3월 30일
Only change you need to make is to add in the first line of the for-loop statement. must add a "-1" to keep from getting an error
for i= 0:EndSecond-1

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by