I want to design butterworth filter in matlab only based on order of the filter and the cutoff frequency in Hz.

the syntax is for returning the ABCD matrix of statespace is

[A,B,C,D] = butter(____)

I tried doing below for 2nd order and 30Hz cut off

[A, B, C, D] = butter(2,30)

But i get an error saying :

Error using butter (line 41)
The cutoff frequencies must be within the interval of

Any help will be appriciated


closed as unclear what you're asking by PlasmaHH, Bence Kaulics, Daniel Grillo, Autistic, Voltage Spike Jun 21 '16 at 15:25

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ Who is giving you the error? M$ Office? \$\endgroup\$ – PlasmaHH Jun 21 '16 at 7:44
  • \$\begingroup\$ I thought it was understood that i was designing in matlab, sorry for confusion. I have edited the question \$\endgroup\$ – Aashu10 Jun 21 '16 at 7:47
  • \$\begingroup\$ "[] = butter(,'s') designs a lowpass, highpass, bandpass, or bandstop analog Butterworth filter with cutoff angular frequency Wn." Directly taken from the help file, please learn how to use other resources other than an online community. IDK if your reading the help file before you post, if your not you should. Please also see electronics.stackexchange.com/help/how-to-ask please follow the recommendations before posting. \$\endgroup\$ – Voltage Spike Jun 21 '16 at 15:24
  • \$\begingroup\$ I'm voting to close this question because not much research was done before posting \$\endgroup\$ – Voltage Spike Jun 21 '16 at 15:25
  • \$\begingroup\$ Hello, Sorry for the confusion. I did check the help. But as you posted, Wn is cutoff angular frequncy, so i just converted my cut off frequency to rads/sec. Which was giving me an error. Turns out Wn was actually normalized cut off frequrency as shown below. \$\endgroup\$ – Aashu10 Jun 22 '16 at 6:23

I'm assuming you are using Matlab to calculate the filter, judging from the syntax and function parameters.

butter calculates a normalized low pass filter response. If you are in the z domain, the actual cut-off frequency depends on your nyquist frequency (half your sampling frequency). If you sample with say 2MSPS, you have a Nyquist frequency of 1MHz and butter with Wn=0.5 would have a cut-off frequency of 500kHz. See also this discussion on matlab central.

You should read "doc butter" to get started and might also want to read a textbook on filter design. From the documentation:

[b,a] = butter(n,Wn) designs an order n lowpass digital Butterworth filter with normalized cutoff frequency Wn. It returns the filter coefficients in length n+1 row vectors b and a, with coefficients in descending powers of z.
  • \$\begingroup\$ Hey! thanks your your detailed answer. i am little behind on some basics. but i want in state space representation. Say i want to desgin a butterworth filter for Cut off frequency of 35Hz. how would i do it '[A,B,C,D] = butter(2, __)' \$\endgroup\$ – Aashu10 Jun 21 '16 at 8:51
  • \$\begingroup\$ As I said, you need to know your sampling rate if you want to relate the normalized frequency Wn to the actual frequency. If you clock your system faster, the cut off frequency will also move up. It doesn't matter whether you design in state space or not. If you want to calculate a continuous filter, you should use the parameter butter( ___, 's'). Again, this works for statespace as well. \$\endgroup\$ – cx05 Jun 21 '16 at 8:53
  • \$\begingroup\$ My Ts = 0.025. I am not sure of the unit you posted. \$\endgroup\$ – Aashu10 Jun 21 '16 at 8:55
  • \$\begingroup\$ The Unit is Megasamples per second. Your Ts would give you 1/Ts = 40 Samples per second (40 SPS). This means that you cannot achieve 30Hz cutoff, because your Nyquist frequency is already at 20Hz. You need a lower Ts to make it work. \$\endgroup\$ – cx05 Jun 21 '16 at 8:56
  • \$\begingroup\$ If Ts is sampling period, invert it to get the sampling frequency, and half that to get the Nyquist frequency. \$\endgroup\$ – Brian Drummond Jun 21 '16 at 8:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.