% Define the sequences x[n] and h[n]
n = 0:3;
x = cos(pi*n);
h = 2*n;
% Compute the four-point DFT of x[n]
X = fft(x);
% Compute the four-point DFT of h[n]
H = fft(h);
% Compute y[n] = x[n] * h[n] using linear convolution
y_linear = conv(x, h);
% Compute y[n] = x[n] * h[n] using DFT
Y = X .* H;
y_fft = ifft(Y);
% Display the results
disp('Four-point DFT of x[n]:')
disp(X)
disp('Four-point DFT of h[n]:')
disp(H)
disp('y[n] using linear convolution:')
disp(y_linear)
disp('y[n] using DFT:')
disp(y_fft)
I tried to prove that direct and convolution and ifft
code give the same results but there need some modification to correct it.