Sie sind auf Seite 1von 3

%% GENERATION OF DISCRETE TIME SEQUENCES USING MATLAB % PROGRAM 1: MATLAB code to generate basic discrete-time signals n = 0:9; %unit

impulse sequence dn = [1,zeros(1,9)]; subplot(3,1,1); stem(n,dn,'r','filled'); title('UNIT IMPULSE SEQUENCE'); xlabel('0<=n<=9'); ylabel('d[n]'); grid on; %unit step sequence un = ones(1,10); subplot(3,1,2); stem(n,un,'r','filled'); title('UNIT STEP SEQUENCE'); xlabel('0<=n<=9'); ylabel('u[n]'); grid on; %ramp sequence rn = n; subplot(3,1,3); stem(n,rn,'r','filled'); title('UNIT RAMP SEQUENCE'); xlabel('0<=n<=9'); ylabel('r[n]'); grid on; % PROGRAM 2: MATLAB code to generate a sinusoidal sequence where and L = input('Desired length = '); A = input('Amplitude = '); omega = input('Angular frequency = '); phi = input('Phase = '); n = 0:L-1; x = A*cos(omega*n + phi); stem(n,x); xlabel('Time index');ylabel('Amplitude'); title(['\omega_{o} = ',num2str(omega)]); % PROGRAM 3: MATLAB code to generate causal discrete-time real exponential sequence n = 0:9; % -1<a<0 a = -0.75; en1=(a*ones(1,10)).^n; subplot(3,1,1); stem(n,en1,'r','filled'); title('discrete-time exponential (-0.75)^n');

xlabel('0<=n<=9'); ylabel('e1[n]'); grid on; % 0<a<1 a = 0.75; en2=(a*ones(1,10)).^n; subplot(3,1,2); stem(n,en2,'r','filled'); title('discrete-time exponential (0.75)^n'); xlabel('0<=n<=9'); ylabel('e2[n]'); grid on; % a>1 a = 1.25; en3=(a*ones(1,10)).^n; subplot(3,1,3); stem(n,en3,'r','filled'); title('discrete-time exponential (1.25)^n'); xlabel('0<=n<=9'); ylabel('e3[n]'); grid on; %% FILTER DESIGN PROGRAM 4: Plot the magnitude and phase responses of the causal IIR digital transfer function . What type of filter does this transfer function represent? Determine 3dB cutoff frequency from the plot. B = conv([1 -2 1],[1 -2 1]); A = conv([1 -1.499 0.8482],[1 -1.5548 0.6493]); freqz(B,A); PROGRAM 5: Design a 5th order elliptic IIR lowpass filter with the following specifications: Passband edge = 0.4 Passband ripple = 0.5 dB Min. stopband attenuation = 40 dB N = input('type in the order = '); Rp = input('type in the passband ripple = '); Rs = input('type in the min. stopband attenuation = '); Wn = input('type in the passband edge frequency = '); [b,a] = ellip(N,Rp,Rs,Wn); fvtool(b,a) PROGRAM 6: Plot highpass filter Passband edge = Passband ripple the magnitude response of a 4th order Chebyshev Type-1 IIR with the following specifications: 0.7 = 1 dB

N = input('type in the order = '); Rp = input('type in the passband ripple = ');

Wn = input('type in the passband edge frequency = '); [b,a] = cheby1(N,Rp,Wn,'high'); fvtool(b,a) PROGRAM 7: Determine the minimum order of the transfer function of a type 2 Chebyshev digital highpass filter operating at a sampling rate of 4 kHz with the following specifications: Passband edge = 1000 Hz Stopband edge = 600 Hz Passband ripple = 1 dB Minimum stopband attenuation = 40 dB FT = input('type in the sampling frequency = '); Fp = input('type in the passband edge frequency = '); Fs = input('type in the stopband edge frequency = '); Rp = input('type in the passband ripple = '); Rs = input('type in the minimum stopband attenuation = '); Wp = Fp/(FT/2); Ws = Fs/(FT/2); [N,Wn]= cheb2ord(Wp,Ws,Rp,Rs); fprintf('order of the filter is %f \n',N);

Das könnte Ihnen auch gefallen