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!