Need help finding a moving average

1 回表示 (過去 30 日間)
Nicholas  Frank
Nicholas Frank 2016 年 3 月 7 日
コメント済み: Nicholas Frank 2016 年 3 月 7 日
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.

採用された回答

Rick Rosson
Rick Rosson 2016 年 3 月 7 日
n = 100;
b = ones(1,n)/n;
a = 1;
absorbance_MA = filter(b,a,absorbance_co2blcorr);
  1 件のコメント
Nicholas  Frank
Nicholas Frank 2016 年 3 月 7 日
Thanks Rick!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by