Need help finding a moving average
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nicholas Frank
am 7 Mär. 2016
Kommentiert: Nicholas Frank
am 7 Mär. 2016
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 Kommentare
Akzeptierte Antwort
Rick Rosson
am 7 Mär. 2016
n = 100;
b = ones(1,n)/n;
a = 1;
absorbance_MA = filter(b,a,absorbance_co2blcorr);
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!