From: James Pau on
Hi there,

I've made a Butterworth filter using the 'buttord' and 'butter' functions in MATLAB which gives me a desirable response. However, when I try to recreate the same filter using the fdatool so that I can generate a block for use in Simulink, the response is quite different (i've checked this on the same input signal).

Would anyone know the reason why this might be?

Thanks in advance,
James
From: Wayne King on
"James Pau" <the_mantis81(a)hotmail.com> wrote in message <hj6n6n$9q8$1(a)fred.mathworks.com>...
> Hi there,
>
> I've made a Butterworth filter using the 'buttord' and 'butter' functions in MATLAB which gives me a desirable response. However, when I try to recreate the same filter using the fdatool so that I can generate a block for use in Simulink, the response is quite different (i've checked this on the same input signal).
>
> Would anyone know the reason why this might be?
>
> Thanks in advance,
> James
Hi James, can you provide the specifics of how you are specifying the filter at the command line and in fdatool?

Thanks,
Wayne
From: James Pau on
"Wayne King" <wmkingty(a)gmail.com> wrote in message <hj6nv3$re3$1(a)fred.mathworks.com>...
> "James Pau" <the_mantis81(a)hotmail.com> wrote in message <hj6n6n$9q8$1(a)fred.mathworks.com>...
> > Hi there,
> >
> > I've made a Butterworth filter using the 'buttord' and 'butter' functions in MATLAB which gives me a desirable response. However, when I try to recreate the same filter using the fdatool so that I can generate a block for use in Simulink, the response is quite different (i've checked this on the same input signal).
> >
> > Would anyone know the reason why this might be?
> >
> > Thanks in advance,
> > James
> Hi James, can you provide the specifics of how you are specifying the filter at the command line and in fdatool?
>
> Thanks,
> Wayne

Hi Wayne, thanks for your response. Here is how the filter is being defined and applied as a function:

function [sig_filt] = butter_low_pass(sig, Fs);
% sig is the input signal and Fs is the sampling frequency

Fpass = 1; % Passband Frequency
Fstop = 3; % Stopband Frequency
Apass = 1; % Passband Ripple (dB)
Astop = 80; % Stopband Attenuation (dB)

% Calculate the order from the parameters using BUTTORD.
[N,Fc] = buttord(Fpass/(Fs/2), Fstop/(Fs/2), Apass, Astop);

% Calculate the zpk values using the BUTTER function.
[z,p] = butter(N, Fc);
sig_filt=filter(z,p,sig);

When using the fdatool, the specifications I use are:
Response type - Lowpass
Design method - IIR butterworth
Filter order - minimum order
Frequency specifications - Fs = 100 Hz (same as in the butter_low_pass function)
Fpass = 1, Fstop = 3
Magnitude specifications - Units = dB, Apass = 1, Astop = 80

As you can see the specifications are the same, and I am aware that the fdatool will use the 'butter' function to design the filter. However, when i export the filter to a simulink model and compare the outputs with the same signal, they're not the same.

Thanks,
James
From: James Pau on
"James Pau" <the_mantis81(a)hotmail.com> wrote in message <hj7qt6$198$1(a)fred.mathworks.com>...
> "Wayne King" <wmkingty(a)gmail.com> wrote in message <hj6nv3$re3$1(a)fred.mathworks.com>...
> > "James Pau" <the_mantis81(a)hotmail.com> wrote in message <hj6n6n$9q8$1(a)fred.mathworks.com>...
> > > Hi there,
> > >
> > > I've made a Butterworth filter using the 'buttord' and 'butter' functions in MATLAB which gives me a desirable response. However, when I try to recreate the same filter using the fdatool so that I can generate a block for use in Simulink, the response is quite different (i've checked this on the same input signal).
> > >
> > > Would anyone know the reason why this might be?
> > >
> > > Thanks in advance,
> > > James
> > Hi James, can you provide the specifics of how you are specifying the filter at the command line and in fdatool?
> >
> > Thanks,
> > Wayne
>
> Hi Wayne, thanks for your response. Here is how the filter is being defined and applied as a function:
>
> function [sig_filt] = butter_low_pass(sig, Fs);
> % sig is the input signal and Fs is the sampling frequency
>
> Fpass = 1; % Passband Frequency
> Fstop = 3; % Stopband Frequency
> Apass = 1; % Passband Ripple (dB)
> Astop = 80; % Stopband Attenuation (dB)
>
> % Calculate the order from the parameters using BUTTORD.
> [N,Fc] = buttord(Fpass/(Fs/2), Fstop/(Fs/2), Apass, Astop);
>
> % Calculate the zpk values using the BUTTER function.
> [z,p] = butter(N, Fc);
> sig_filt=filter(z,p,sig);
>
> When using the fdatool, the specifications I use are:
> Response type - Lowpass
> Design method - IIR butterworth
> Filter order - minimum order
> Frequency specifications - Fs = 100 Hz (same as in the butter_low_pass function)
> Fpass = 1, Fstop = 3
> Magnitude specifications - Units = dB, Apass = 1, Astop = 80
>
> As you can see the specifications are the same, and I am aware that the fdatool will use the 'butter' function to design the filter. However, when i export the filter to a simulink model and compare the outputs with the same signal, they're not the same.
>
> Thanks,
> James

Hi all,

I figured out what my problem was. The outputs do match - it was just a matter of distinguishing the results in real time.

Thanks for the interest anyway.
James