0% found this document useful (0 votes)
22 views

Matlab Solution PDF

This document contains MATLAB code that performs Fourier analysis on various signals. It generates plots of the Fourier transforms of different signals, including a rectangular pulse, sums of sinusoids, and windowed sums of sinusoids. It explores the effects of changing the signal length and zero-padding on the resolution of the Fourier transforms.

Uploaded by

Satheeskumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views

Matlab Solution PDF

This document contains MATLAB code that performs Fourier analysis on various signals. It generates plots of the Fourier transforms of different signals, including a rectangular pulse, sums of sinusoids, and windowed sums of sinusoids. It explores the effects of changing the signal length and zero-padding on the resolution of the Fourier transforms.

Uploaded by

Satheeskumar
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

%10.

M = 64;
w =(-pi:0.001:pi);
X = (sin(w*M/2)./sin(w/2)).*exp(-1j*w*(M-1)/2);
figure(1);
plot(w/pi,abs(X))
title('10.3(a)')
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('|W(e^j^\omega)|');

A0=1;
A1=0.75;
T=(1/10000);
O0=(2*pi/6)*10000;
O1=(2*pi/3)*10000;
w0=O0*T;
w1=O1*T;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
figure(2)
subplot(221);
plot(w/pi,abs(V));
title('10.3(b)')
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('|V(e^j^\omega)|');

O0=(2*pi/14)*10000;
O1=(4*pi/15)*10000;
w0=O0*T;
w1=O1*T;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
subplot(222);
plot(w/pi,abs(V));
title('10.3(c)')
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('|V(e^j^\omega)|');

O0=(2*pi/14)*10000;
O1=(2*pi/12)*10000;
w0=O0*T;
w1=O1*T;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
subplot(223);
plot(w/pi,abs(V));
title('10.3(d)')
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('|V(e^j^\omega)|');

O0=(2*pi/14)*10000;
O1=(4*pi/25)*10000;
w0=O0*T;
w1=O1*T;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
subplot(224);
plot(w/pi,abs(V));
title('10.3(e)')
xlabel('Normalized freq. (Nyquist freq. = 1)')
ylabel('|V(e^j^\omega)|');

%(B) 10.6
N=64;
n=0:N-1;
v=cos((2*pi/16).*n)+0.75*cos((2*pi/8).*n);
subplot(211);
stem(n,v);
axis([-1,65,-2,2]);
title('10.6(a)')
xlabel('n')
ylabel('Amplitude,v[n]');

A=fft(v,N);
subplot(212);
hold on;
stem(n,abs(A));
A0=1;
A1=0.75;
w0=(2*pi)/16;
w1=(2*pi)/8;
M=64;
w=0:0.001:2*pi;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
plot((w*N)/(2*pi),abs(V));
hold off;
title('10.6(b)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');

%10.7
N=64;
n=0:N-1;

v=cos((2*pi/16).*n)+0.75*cos((2*pi/8).*n);
k=0:127;
N=64*2;
A=fft(v,N);
figure(1);
hold on;
stem(k,abs(A));

A0=1;
A1=0.75;
w0=(2*pi)/16;
w1=(2*pi)/8;
M=64;
w=0:0.0001:2*pi;

M1=((A0/2)*(sin((w-w0)*M/2)./sin((w-w0)/2)).*exp(-1j*(w-w0)*(M-1)/2));
M2=((A0/2)*(sin((w+w0)*M/2)./sin((w+w0)/2)).*exp(-1j*(w+w0)*(M-1)/2));
M3=((A1/2)*(sin((w-w1)*M/2)./sin((w-w1)/2)).*exp(-1j*(w-w1)*(M-1)/2));
M4=((A1/2)*(sin((w+w1)*M/2)./sin((w+w1)/2)).*exp(-1j*(w+w1)*(M-1)/2));
V=M1+M2+M3+M4;
plot((w*N)/(2*pi),abs(V));
hold off;
title('10.7')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');
%10.8(a)

a = kaiser(64,5.48);
w=a';
N=64;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));
subplot(221);
stem(n,v);
title('10.8(a)')
xlabel('n')
ylabel('v[n],Amplitude');

%10.8(b)

a = kaiser(64,5.48);
w=a';
N=64;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));

V=fft(v,N);
subplot(222);
stem(n,abs(V));
hold on;
V=fft(v,1024);
A = linspace(0,64,1024);
plot(A,abs(V));
hold off;
title('10.8(b)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');

%10.8(c)

a = kaiser(32,5.48);
w=a';
N=32;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));
subplot(223);
stem(n,v);
title('10.8(c)')
xlabel('n')
ylabel('v[n], Amplitude');
%10.8(d)
V=fft(v,N);
subplot(224);
stem(n,abs(V));
hold on;
V=fft(v,1024);
A = linspace(0,32,1024);
plot(A,abs(V));
hold off;
title('10.8(d)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');

%10.9(a)

a = kaiser(32,5.48);
w=a';
N=32;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));

V=fft(v,N);
subplot(311);
stem(n,abs(V));
hold on;
V=fft(v,1024);
A = linspace(0,32,1024);
plot(A,abs(V));
hold off;
title('10.9(a)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');
%10.9(b)

a = kaiser(32,5.48);
w=a';
N=32;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));
k=64;
l=0:63;
V=fft(v,k);
subplot(312);
stem(l,abs(V));
hold on;
V=fft(v,1024);
A = linspace(0,64,1024);
plot(A,abs(V));
hold off;
title('10.9(b)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');

%10.9(c)

a = kaiser(32,5.48);
w=a';
N=32;
n=0:N-1;
v=(w.*cos((2*pi/14).*n))+(w.*0.75.*cos((4*pi/15).*n));
k=128;
l=0:127;
V=fft(v,k);
subplot(313);
stem(l,abs(V));
hold on;
V=fft(v,1024);
A = linspace(0,128,1024);
plot(A,abs(V));
hold off;
title('10.9(c)')
xlabel('k,wN/2\pi')
ylabel('|V[k]|,|V(e^jw)|');

You might also like