Error While Using the butter() function for IIR Butterworth filter design

5 Ansichten (letzte 30 Tage)
I am using Matlab 2012a. My code for the design of IIR Butterworth filter is:
clc
clear all
Fs=1000;
fc=300;
WC=2*pi*fc;
N=5;
[b,a]=butter(N,WC,'s');
[z,p,k]=butter(N,WC,'s');
[bz,az]=ipminvar(b,a,Fs);
[h, f]=freqz(bz,az,512,Fs);
plot(f, 20*log10(asb(h))),grid;
xlabel('frequency(Hz)');
ylabel('Magnitude(dB)');
The error encountered after execution of the program is:
??? Attempt to execute SCRIPT butter as a function: E:\Academics\6th Sem\DSP Lab\Exp-8\butter.m
Error in ==> butter at 8 [b,a]=butter(N,WC,'s');
Signal Processing Toolbox is already present in my Matlab. I have checked it using
>>ver
Please help me to debug the problem.

Akzeptierte Antwort

Wayne King
Wayne King am 4 Apr. 2012
I don't see where you are using butter() at all in the code you have posted here. This is an FIR filter design. Did you copy and paste the wrong code?
At any rate, do not name a script, or variable the same name as an exisiting MathWorks' function. If you really have a script named butter.m on your path (E:\Academics\6th Sem\DSP Lab\Exp-8\butter.m) , then rename that to something like my_butter.m, anything but butter. Then enter
>>which butter
and make sure you get something like:
matlab\toolbox\signal\signal\butter.m
returned.
  4 Kommentare
Wayne King
Wayne King am 4 Apr. 2012
BTW, you have another spelling error: it's abs() not asb()
plot(f, 20*log10(abs(h))),grid;
Arnab Ray
Arnab Ray am 4 Apr. 2012
thanks a lot!! the program is working and I got the correct graph..

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Honglei Chen
Honglei Chen am 4 Apr. 2012
This error
??? Attempt to execute SCRIPT butter as a function: E:\Academics\6th Sem\DSP Lab\Exp-8\butter.m
indicates that you have a butter.m on your path that shadowed MATLAB's butter() function. You need to either remove it from the path or change its name to something other than butter.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by