How to create a test bench waveform for the working of band pass and low pass filter

Hi,
I created a band pass filter and low pass filter through sptool in matlab and imported the co-efficients into workspace
Now I need to write a testbench for the working of these filters.
Can anyone suggest something about this
Thanks in advance

 Accepted Answer

Hi Vivek,
What is the purpose of the test bench? If you purpose is to look at the filter response, then in my opinion it is better to examine the filter response. Say you have the filter coefficients b and a, then you can do
>> fvtool(b,a)
to look at the response.
If you really want to pass the data, you can use randn to generate some white noise data and then run it through the filter, e.g.,
>> x = randn(1024,1);
>> y = filter(b,a,x);
HTH

6 Comments

Hi,
Thanks for ur reply
I used this command where b,a given as the filter co-efficients of bandpass filter imported into workspace from sptool.
I got the array size for Y as 1024*1 double
Actually what happend by using this command
Thanks in advance
Hi,
Thanks for ur reply
I need to create a test bench for the verification the specified amplitude- and phase transfer functions of the calculated IIR lowpass and bandpass filters
My friend used this function to create bandpass filter
Z=filterIIR2t(Mxr,Num1,Den1); %to create band pass filter
where Num1,Den1 are filter co-efficients and defined this
function as which is used as test bench
function y = filterIIR2t(x,Num,Den)
c=Num;
d=Den;
sz=size(Num);
k=sz(2)-1;
reg=zeros(k,1);
ind=1;
for v=x
y(ind)=v*c(1)+reg(1);
reg(1:k-1)=(v*c(2:k)-y(ind)*d(2:k))'+reg(2:k);
reg(k)=v*c(k+1)-y(ind)*d(k+1);
ind=ind+1;
end;
Can u explain me what this function will do
Thanks in advance
Hi Vivek,
If I'm not mistaken, the test bench coded you showed performs the filtering. This is exactly what filter() does in my example. X is your input and Y is your output, i.e., the filtered signal.
Hi Vivek, from what I can tell by the name of your colleague's function, it should be implementing a direct-form II transposed structure. The built-in MATLAB filter() which Honglei has recommended also uses a direct-form II transposed structure.
Hi,
Thanks for ur reply
So,without using my friends testbench function filterIIR2t(x,Num,Den) we can directly use inbuilt function
filter(b,a,x)
But when I am using this function filter(b,a,x) I am not getting any response
Can u suggest me something about this
Thanks in advance
Did you design your filter as a filter object, or as coefficients.
filter() also works with filter objects, so if you have a filter object, use
filter(Hd,x) where Hd is your object
if you have coefficients, then b should be Num and a should be Den
filter(Num,Den,x)

Sign in to comment.

More Answers (0)

Products

Asked:

Jim
on 27 Sep 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!