Running mean normalization

8 views (last 30 days)
David Craig
David Craig on 16 Dec 2011
Hi, I am trying to normalize a time series by using a running mean. It should compute the running average of the absolute value of the waveform in a normalization time window of fixed length and then weight the waveform at the centre of the window by the inverse of this average.The idea is to remove some high amplitude events (that effect all frequencies) from the data. The data is first filtered in a band that allows the events to be seen clearly and the weights calculated from this filtered data. The weights are then applied to the unfiltered data, this should have the effect of removing the large events and normalizing the data while preserving the amplitude information.I'm having alot of trouble trying to implement it, my code is below, anyone able to help??
clear
close all
N=50;
low = 800;
high = 850;
t1 = [ 0 : 1 : 1000 ]; % Time Samples
f1 = 50; % Input Signal Frequency
fs1 = 8000; % Sampling Frequency
x1 = sin(2*pi*f1/fs1*t1); % Generate Sine Wave
t1 = [ 0 : 1 : 1000 ]; % Time Samples
f1 = 50; % Input Signal Frequency
fs1 = 8000; % Sampling Frequency
x1 = sin(2*pi*f1/fs1*t1); % Generate Sine Wave
x1(low:high) = x1(low:high)+x2;
figure; plot(x1)
x3 = bp(x1,1/fs2,450,550);
figure; plot(x3);
for i=1:2*N
wind = x3(1:i+N-1);
weights(i) = (sum(abs(wind)))/((2*N)+1);
end
for i=N+1:length(x1)-N
i;
wind = x3(i-N+1:i+N);
weights(i) = (sum(abs(wind)))/((2*N)+1);
end
for i=length(x1)-2*N+1:length(x1)
wind = x3(i:length(x1));
weights(i) = (sum(abs(wind)))/((2*N)+1);
end
x4=x1./weights;
figure; plot(x4)
[r p] = corrcoef(x1(1:low-100),x4(1:low-100))
  1 Comment
bym
bym on 17 Dec 2011
is this the entire code? There are some undefined variables

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!