convolve 1 dimension of matrix in matlab

In Matlab, you can convolve a 1-dimensional signal with a filter using the "conv" function. Here is an example:

main.m
% generate a random signal and filter
x = rand(1,100);        % 1x100 random signal
f = ones(1,10)/10;      % 1x10 moving average filter

% convolve the signal with the filter
y = conv(x,f,'same');   % 'same' returns central part of solution
242 chars
7 lines

In this example, we first generate a random signal x with 100 elements and a moving average filter f with a length of 10 elements. We then use the conv function to convolve x with f, and specify the 'same' parameter to return the central part of the resulting sequence with the same length as the original x.

The resulting sequence y contains the convolved signal.

gistlibby LogSnag