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?
-
\$\begingroup\$ Have you tried 'gensig'? \$\endgroup\$– ChuSep 25, 2017 at 12:07
-
\$\begingroup\$ What band pass and band stop levels do you need? expect ?+/-1kHz and if breakpoints are -3dB. \$\endgroup\$– Tony Stewart EE75Sep 25, 2017 at 13:40
-
\$\begingroup\$ I'm not sure how the decibel values come into play here? @TonyStewart.EEsince'75 \$\endgroup\$– GordonSep 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\$– Tony Stewart EE75Sep 25, 2017 at 14:04
-
\$\begingroup\$ Your filter is poorly defined and so it will respond the same. \$\endgroup\$– Tony Stewart EE75Sep 25, 2017 at 14:35
1 Answer
There are a number of ways to do this and each have their merits
Simulink.
The most visually intuitive method to perform what you are requestingMatlab 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);
-
\$\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\$– GordonSep 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\$– GordonSep 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\$– user16222Sep 25, 2017 at 14:27