Gaussian moving average on dataset with replicate analyses

조회 수: 2 (최근 30일)
Robin Vorsselmans
Robin Vorsselmans 2018년 5월 20일
댓글: Robin Vorsselmans 2018년 5월 20일
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?

답변 (1개)

Ameer Hamza
Ameer Hamza 2018년 5월 20일
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
Robin Vorsselmans
Robin Vorsselmans 2018년 5월 20일
that's what I did initially but I actually want all the data points of the same date to get the same weight and then move the window by one day.
Robin Vorsselmans
Robin Vorsselmans 2018년 5월 20일
it's allright guys, I made the data equally spaced and built a monster of a loop. The dataset isn't too big so this should do. thx for all the help

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Chemistry에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by