Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please complete Part C using MATLAB. Below is the MATLAB code I have for Part A

ID: 3348973 • Letter: P

Question

Please complete Part C using MATLAB. Below is the MATLAB code I have for Part A and B

clc;
close all;

for n = 1:32
x(n) = 0.9*(n-1)*cos(0.1*pi*(n-1));
end

%code for part a)

figure()
subplot(4, 1, 1);
plot(x);
xlabel('time');
ylabel('amplitude');
title('Input signal');

%code for part b)

subplot(4, 1, 2);
plot(real(fft(x,32)));
xlabel('frequency');
ylabel('amplitude');
title('Real part of fft of the signal');

subplot(4, 1, 3);
plot(imag(fft(x,32)));
xlabel('frequency');
ylabel('amplitude');
title('Imaginary part of fft of the signal');

subplot(4, 1, 4);
plot(dct(x,32));
xlabel('frequency');
ylabel('amplitude');
title('DCT of the signal');

% code for part c)
xdft = fft(x, 32);

MATLAB problem. This problem illustrates the energy compaction property of the DCT in relation to the DFT. Consider the finite duration signal x(n) = (0.91 cos(0.1m) for 0

Explanation / Answer

Hello user,

Please find the whole code attached.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

clc;
close all;

for n = 1:32
x(n) = 0.9*(n-1)*cos(0.1*pi*(n-1));
end

%code for part a)

figure()
subplot(4, 1, 1);
plot(x);
xlabel('time');
ylabel('amplitude');
title('Input signal');

%code for part b)

subplot(4, 1, 2);
plot(real(fft(x,32)));
xlabel('frequency');
ylabel('amplitude');
title('Real part of fft of the signal');

subplot(4, 1, 3);
plot(imag(fft(x,32)));
xlabel('frequency');
ylabel('amplitude');
title('Imaginary part of fft of the signal');

subplot(4, 1, 4);
plot(dct(x,32));
xlabel('frequency');
ylabel('amplitude');
title('DCT of the signal');

% code for part c)
N=32;
xdft_base = fft(x, N);
m=1:2:31;
for i=1:16
xdft = fft(x, N);
k=(N+1-m(i))/2:(N-1+m(i))/2;
xdft(k)=0;
xmdft(i,:)=xdft;
ximdft(i,:)=ifft(xmdft(i,:),N);
errordft(i)=norm(ximdft(i,:)-x,2)^2;
end
figure
stem(m,errordft);
title('Error DFT plot');

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

Please comment if you have any doubt.

Thank you.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote