Electrical – How to pass a square wave through transfer function in MATLAB

band passMATLABpassive-networks

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?

Best Answer

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