0
\$\begingroup\$

I am currently trying to create a band stop filter which attenuates frequencies between 2000Hz and 8000Hz. I have got the transfer function but now I am struggling to find the documentation on how to pass a square wave of 6000Hz and another sqaure wave of 20 000Hz to test the filter. I am doing this on MATLAB or Octave so any help will be appreciated. Should I be using the step function to get the frequency response graph?

\$\endgroup\$
6
  • \$\begingroup\$ Have you tried 'gensig'? \$\endgroup\$
    – Chu
    Sep 25, 2017 at 12:07
  • \$\begingroup\$ What band pass and band stop levels do you need? expect ?+/-1kHz and if breakpoints are -3dB. \$\endgroup\$ Sep 25, 2017 at 13:40
  • \$\begingroup\$ I'm not sure how the decibel values come into play here? @TonyStewart.EEsince'75 \$\endgroup\$
    – Gordon
    Sep 25, 2017 at 14:01
  • \$\begingroup\$ All filters ought to be defined by dB in passband @ f1,f2 and bandstop @ f3,f4 also consider phase shift , amplitude ripple. It needs to be high order and TI.com has excellent tools. \$\endgroup\$ Sep 25, 2017 at 14:04
  • \$\begingroup\$ Your filter is poorly defined and so it will respond the same. \$\endgroup\$ Sep 25, 2017 at 14:35

1 Answer 1

1
\$\begingroup\$

There are a number of ways to do this and each have their merits

  1. Simulink.
    The most visually intuitive method to perform what you are requesting

  2. Matlab script using ft, gensig & lsim

    H = tf(1,[1e-3 1]);
    [sig,t] = = gensig('square',10e-3,50e-3,1e-6);
    lsim(H,sig,t);

enter image description here

\$\endgroup\$
3
  • \$\begingroup\$ I'm currently looking at the gensig documentation which seems to be what I need to use. But how do I set the frequency of the wave? Because I noticed that you set your period as 1ms, your duration as 0.05ms and sampling as 1ns. Why did you choose these values? @JonRB \$\endgroup\$
    – Gordon
    Sep 25, 2017 at 14:07
  • \$\begingroup\$ Ideally my period should be 1/f where f is the frequency of the specified wave I am trying to create. @JonRB \$\endgroup\$
    – Gordon
    Sep 25, 2017 at 14:11
  • \$\begingroup\$ I set the frequency by the period. Period = 1/f. I set the period to be 10ms so the 1/2 period would be 5ms so a transfer function with a 1ms time constant would be at 5 time constant. I set 50ms so I would have 5 complete cycles and 1us (not 1ns) so the fidelity was enough for a plot. Basically all for visual example NOT anyone specific case \$\endgroup\$
    – user16222
    Sep 25, 2017 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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