You are on page 1of 3

%Name:-Bhamare Kishor D.

%MIS No.141305012
%Programe for Calculation of Fourier Series Coefficients
clc
clear
N=16;
n=0:15;
x=2+5*sin(3*pi*n/2)+6*cos(pi*n/8);
z=zeros(1,N);
for k=0:N-1;
for n=0:N-1;
z(k+1)=z(k+1) + (x(n+1)*exp(-1i*2*pi*n*k/N))/N;
end
end
Z(1,1)=2;
t=0:N-1;
stem(t,abs(z));
Results:-

%Programe for Calculation of DFT of Input Signal

clc;
clear all;
q=input('Enter iteration=');
s=((2*pi)/12);
y=zeros(1,q);
z=zeros(1,q);
for i=1:q;
x=2*cos(s*(i-1));
y(1,i)=x;
end;
for i=1:q;
x=4*sin(s*(i-1));
z(1,i)=x;
end;
t=0:1:q-1;
subplot(2,2,1);
stem(t,y);
xlabel('N');
ylabel('Magnitude of First Input Signal');
hold on;
h=y+z;
t=0:1:q-1;
subplot(2,2,2);
stem(t,z);
xlabel('N');
ylabel('Magnitude of Second Input Signal');
hold on;
%programe for Discrete fourier Transform
n=length(h);
l=zeros(1,n);
a=((2*pi)/12);
for k=1:n;
for j=1:n;
l(k)=l(k)+h(j)*exp(-1i*a*(j-1)*(k-1));
end;
end;
disp('Fourier Transform Result of Input Signal');
disp(l);
p=abs(l);
q=imag(l);
r=angle(l);
s=real(l);
t=0:1:n-1;
subplot(2,2,3);
stem(t,p);
hold on;
xlabel('N');

ylabel('Magnitude of DFT ');


title('Discrete Time Fourier Transform');

Result:-

You might also like