To perform a 1 dimensional convolution in Matlab, you can use the built-in function conv
. Here is an example of how to use it:
main.m349 chars17 lines
In this example, we first create a sinusoidal signal to filter (y
). We then create a filter kernel that applies a moving average over 5 samples. We then use the conv
function to filter the signal with the kernel. The 'same'
option specifies that the output is the same size as the input. We then plot the original signal (y
) in blue and the filtered signal (y_filtered
) in red.
gistlibby LogSnag