First differences filter

First, you should read up on Matlab’s documentation of the filter function. If you just want to take a first difference, what you’re looking to generate is the series:

1 * y(n) = 1 * x(n) - 1 * x(n - 1)

Which corresponds to the vector a = 1, and b = [1, -1], so your Matlab code would look like:

y = filter([1,-1],1,x); 

Leave a Comment