I have designed a Parks-McClellan filter using the code below in MATLAB----
I want to create the above mentioned signal (x(n)) and then pass it through this filter to check the output. But I am not sure how to generate the signal and then how to pass it through the filter in matlab.
clc; clear all; close all;
wp =0.36;
ws =0.4;
Rp =0.1;
As = 40;
delta1 = (10^(Rp/20)-1)/(10^(Rp/20)+1);
delta2 = (1+delta1)*10^(-As/20);
f = [wp ws];
m =[1 0];
DEV =[delta1 delta2];
[M F0 A0 W0]=firpmord(f, m, DEV);
h = firpm(M, F0, A0, W0);
[H, W]= freqz(h,1);
plot(W/pi, 20*log10(abs(H)))
grid minor
Signal Processing Toolbox and
filter()
FunctionTo declare the signal,
x[n]
a vector can be created in terms ofn
that ranges from0
to499
. Using element-wise multiplication in the equation ofx[n]
.*
will allow you to evaluate the function for every point/value ofn
.Using the
filter()
function maybe an option if you have the Signal Processing Toolbox installed. Thefilter()
function allows you to pass the coefficients of the filter,h
and signal you wish to filter out. This function returns back the filtered signal in this exampled declared as variabley
. Below is a plot that shows the original vs the filtered out signal: