%Copyright (C) 2019 Jan Christian Rohde
%
%This file is part of MACE.
%
%MACE is free software; you can redistribute it and/or modify it under the terms of the
%GNU General Public License as published by the Free Software Foundation; either version 3
%of the License, or (at your option) any later version.
%
%MACE is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
%even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%GNU General Public License for more details.
%
%You should have received a copy of the GNU General Public License
%along with MACE; if not, see http://www.gnu.org/licenses.
% This script contains examples concerning discrete signals.
setCharacteristic(0)
% First sample a discrete signal with frequencies 1 / (2 pi) and 1 / (4 pi)
s=sampling(cos(x)+sin(x/2),1,0,100):
% fast fourier transform
f=fft(s):
plot(abs(f));
% filter the signal with low frequency 1 / (4 pi)
p=lowPass(s,0.1);
plot(sin(x/2),real(p));
% An iir system and its impulse response:
% Note the system is the one given by the polynomials with inverted powers
% with respect to usual conventions 2*x^(-3)+6*x^(-2)+2*x,1.5+1.2*x^(-5)
s=setSize(seq(1),100):
r=iir(s,2*x^3+6*x^2+2*x,1.5+1.2*x^5):
% you should enlarge the x-axis domain of the plot by hand to see more of the
% impulse response
plot(real(r));