Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Ashok Kumar
Reg. Number: 9908005035
Date:21.07.2010
Exp. No. 4 Name of the Experiment: Continuous and Discrete signal generation
clc;
clear all;
close all;
N = length(x_n)+length(h_n)-1;
x_k = dft(x_n,N); % Call of user defined function dft
h_k = dft(h_n,N);
mag_xk = abs(x_k);
ang_xk = angle(x_k);
mag_hk = abs(h_k);
ang_hk = angle(h_k);
n = 0:1:N-1;
subplot(3,2,3);
stem(n,mag_xk)
title ('DFT of x(n) vector x(k)');
xlabel ('samples "n"');
ylabel ('Amplitude');
subplot(3,2,4);
% Inverse DFT
y_k = x_k.*h_k;
N2 = length(y_k);
y_n = idft(y_k,N);
subplot(3,2,5);
stem(n,abs(y_n));
title ('IDFT of x(k)&h(k)or circular convolution by DFT');
xlabel ('samples "n"');
ylabel ('Amplitude');
disp('circular convolution output signal');
disp(abs(y_n));
subplot(3,2,6);
stem(n,conv(x_n,h_n));
% Functions:
% file name : D_I
function [w,y] = DI(ak,bk,xn,LT,Ld)
% Direct for I
% To find w(n)
%%
% To find y(n)
y = zeros(1,LT);
WD = zeros(1,Ld);
for N = 1:LT
for K = 2:Ld
if ((N-K) >= 0)
WD(K) = bk(K)*y(N-K+1);
end
end
y(N) = sum(WD) + w(N);
WD = zeros(1,Ld);
end
u = zeros(1,LT);
Wd = zeros(1,Ld);
for N = 1:LT
for K = 2:Ld
if ((N-K) >= 0)
Wd(K) = bk(K)*u(N-K+1);
end
end
u(N) = sum(Wd) + xn(N);
Wd = zeros(1,Ld);
end
for n = 1:LT
for k = 1:LT