Geoscience Reference
In-Depth Information
Here, we see that the actual input series x1 has a length of 100 data points,
whereas the output y1 has two additional elements. Convolution generally
introduces ( m -1)/2 data points at each end of the data series. To compare
input and output signals, we therefore clip the output signal at either end.
y1 = y1(2:101,1);
A more general way to correct the phase shit s of conv is
y1 = y1(1+(m1-1)/2:end-(m1-1)/2,1);
which of course only works for an odd number of i lter weights. An alternative
is to use same for the shape parameter in conv(a,b,shape) in order to return
the most central 100 data points of the convolution that have the same size
as the input signal x1 .
y1 = conv(x1,b1,'same');
We can then plot both input and output signals for comparison, using legend
to display a legend for the plot.
plot(t,x1,'b-',t,y1,'r-')
legend('x1(t)','y1(t)')
h is plot illustrates the ef ect that the running mean has on the original input
series. h e output y1 is signii cantly smoother than the input signal x1 . If we
increase the length of the i lter we obtain an even smoother signal output y2 .
b2 = [1 1 1 1 1]/5;
m2 = length(b2);
y2 = conv(x1,b2,'same');
plot(t,x1,'b-',t,y1,'r-',t,y2,'g-')
legend('x1(t)','y1(t)','y2(t)')
h e reverse of convolution is deconvolution, which is ot en used in signal
processing to reverse the ef ects of a i lter. We use the i rst example of a
random signal x1 , design a i lter that averages three data points of the input
signal, and convolve the input vector with the i lter, which yields the output
y1 .
clear
t = (1:100)';
rng(0)
x1 = randn(100,1);
Search WWH ::




Custom Search