Gaussian moving average on dataset with replicate analyses
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hey Guys,
I got isotopic abundance data of samples that come from a different period in the past, but sometimes I have more than 1 measurement per sample/time. I want to smooth my data using a gaussian window but I can't figure out how to smooth my data in the time domain.
minimum working example. % create a matrix with replicate time values, probably not import but let's say that time here is days
time = [1 1 2 3 3 3 4 4 4 4 5 6 6 6 6 6 7 7 8 8 9 9 9 10];
% create associated values
data = [0.43 0.44 0.45 0.44 0.46 0.48 0.49 0.50 0.49 0.52 0.55 0.52 0.51 0.53 0.52 0.55 0.49 0.49 0.46 0.45 0.44 0.40 0.41 0.35]
%create 5-day gaussian window and normalize
w = gausswin(5)/sum(gausswin(5))
Now I want to use this gaussian window to smooth my data set by moving it with a 1 day timestep. But I want all replicates to be incorporated. I also would like to add a conditional, so that it skips a day when there aren't enough replicates in the window.
Does anyone have an idea on how to do this?
0 Kommentare
Antworten (1)
Ameer Hamza
am 20 Mai 2018
If you want to apply gaussian window smoothing on the data matrix then you can use conv with one vector flipped.
smoothedData = conv(data, fliplr(w))
smoothedData = smoothedData(length(w):end-length(w)+1); % to only get the data points in which the window fully fits the |Data| matrix.
7 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!