I’ve been given the formula below to apply to a signal. I’m not sure how to plug this into Matlab, can anyone explain?
y(n) =1/8[2x(n) + x(n − 1) − x(n − 3) − 2x(n − 4)]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If
xis your input signal andyis your output, the expression you have can be regarded as an FIR filter. You can write the coefficients ofxin a vector asb = (1/8)*[2, 1, 0, -1, -2];(the 0 in the middle is the coefficient ofx(n-2)). Then you can apply it to your input data vectorxusing thefilterfunction:y = filter(b, 1, x);(the 1 in the middle represents the coefficient ofy(n)).It may also be of interest to see the frequency response of the filter. To do so, you can use the
freqzcommand:freqz(b,1);. See the documentation for more details, including how to calibrate the x-axis of the plot in Hz. Use of this function requires the Signal Processing Toolbox from the Mathworks.