Need help finding a moving average
조회 수: 2 (최근 30일)
이전 댓글 표시
I'm trying to determine the moving average of a file with several columns. Each column is a separate data set and I want to find a moving average of each data set. I can't seem to figure out how to deal with each column by itself, so I basically append each data set ontop of each other and make a very large single string of values, and deal with it that way. I nkow this isn't the best way to do this, but that's what my code does now. Once that's done (which my code successfully does), I want to extract the values from this large string and rearrange it into columns again. I'm having trouble doing this...my code is as follows
function [absorbance_MA] = co2_quantify(wave_number, absorbance_co2blcorr);
numFiles = 5;
n = 100; %defines period of moving average
for i = n:numFiles*length(absorbance_co2blcorr)-n
absorbance_MA_bl(i) = mean(absorbance_co2blcorr(i:i+n));
end
for i = 0:numFiles-1
absorbance_MA(:,i+1) = absorbance_MA_bl(length(absorbance_co2blcorr)*i+1:length(absorbance_co2blcorr)*(i+1)-n)';
end
Any help is appreciated. I've attached the relevant files needed to run the code.
댓글 수: 0
채택된 답변
Rick Rosson
2016년 3월 7일
n = 100;
b = ones(1,n)/n;
a = 1;
absorbance_MA = filter(b,a,absorbance_co2blcorr);
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!