1、delta = imp_fun(n,n0)where n is a vector of sequential integers and n0 is an integer marking the location of the impulse. For example, the commands n = 0:6;y = imp_fun(n,3);stem(n,y)The impulse function generator can be used to build more complex signals, like yn = 5n - n-2:y=5*imp_fun(n,0) - imp_fu
2、n(n,2);stem(n,y)The function step_fun produces the impulse function un-n0 as follows:u = step_fun(n,n0)where n is a vector of integers and n0 is an integer marking the beginning of the step. For example, the commandsn = -3:7;u = step_fun(n,2);stem(n,u)produces the plot below.A plot of a rectangular
3、pulse like xn = 2(un un-4) may be produced with the commands:n = -2:7;x = 2*(step_fun(n,0)-step_fun(n,4);stem(n,x)Exponential functions can be generated in Matlab using the exp function. For example, the function xn = 2e-0.5n can be plotted using the commands: n = -2:6;x = 2*exp(-0.5*n);stem(n,x)Sam
4、ples of the power function xn = (-0.9)nun are produced as follows:n = -3:8;x = (-0.9).n.*step_fun(n,0);Digital sinusoids are produced using the sin and cos functions provided by Matlab. Some examples are x = 3*sin(pi/8*n) and x = -cos(5*pi/7*n-pi/3), which generate the functions xn = and xn = . Anal
5、og frequencies in Hertz may be converted to digital frequencies in radians using the formulaThe a2d function performs this computation:omega = a2d(f,fs);where omega = . For example, for a sampling frequency of 11025 Hz and an analog frequency 500 Hz, the commandomega = a2d(500,11025)gives 0.0907, so
6、 the corresponding digital frequency is 0.0907. Digital frequencies may be converted into analog frequencies in Hertz using the formula:The function d2a performs the conversion as follows:f = d2a(omega,fs);where omega = . For example, for a sampling frequency of 16 kHz, the digital frequency 0.35 radians corresponds to f = d2a(0.35,16000);or 2800 Hz.