clc
clear all
close all
X=input('Enter the Input Sequence');
N=input('Enter the N value such that N-point DFT is calculated');
%Inputs are given%
L=length(X);
if N>L
X=[X zeros(1,N-L)];
else
X=X(1:N);
end%Adjusting the Length of the input Sequence by appending Zeros or truncating the sequence%for k=1:N
key=0;
for n=1:N
key=key+X(n)*exp(-(j*2*pi*(k-1)*(n-1))/N);
end
Y(k)=key;
end%DFT is calculated%
Y %DFT is printed%
L=length(Y);
n=0:1:L-1;
figure,plot(n,abs(Y)),title('Magnitude Response of DFT')
figure, plot(n, angle(Y)), title('Phase Response of DFT')
%MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED%for k=1:N
key=0;
for n=1:N
key=key+Y(n)*exp((j*2*pi*(k-1)*(n-1))/N);
end
Yinv(k)=key/N;
end%IDFT is calculated%
Yinv
L=length(Y);
n=0:1:L-1;
figure,plot(n,abs(Yinv)),title('Magnitude Response of IDFT')
figure, plot(n, angle(Yinv)), title('Phase Response of IDFT')
%MAGNITUDE and PHASERESPONSE OF ORIGINAL SIGNAL IS PLOTTED%%We are going to get a very minute phase due to the approximations of exponent values in the order of 10^-15%
Error using input
Cannot call INPUT from EVALC.
Error in dftidft2 (line 5)
X=input('Enter the Input Sequence');
dftidft3 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the value of N such taht N-point DFT is to be calculated' ); %Inputs are taken% n=0:1:N-1; k=0:1:N-1; nk=n'*k; %n transpose * k gives us a N*N matrix% W=exp(-(j*2*pi)/N); % Twiddle Factor % Wnk=W.^nk; % Twiddle Factor matrix is generated % Y= Wnk*X' ; % Twiddle factor matrix multiplied by X transpose% %Reason behing going to Transopose of the input matrix is : when we enter a matrix sequence we usually use ROW Matrix, in order to convert ROW to COLUMN we are using Transpose% L=length(Y); n=0:1:L-1; figure,plot(n,abs(Y)),title( 'Magnitude Response of DFT' ) figure, plot(n, angle(Y)), title( 'Phase Response of DFT' ) %MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED% W=exp((j*2*pi)/N); % Twiddle Factor % Wnk=(W.^nk)/N; % Twiddle Factor matrix is generated % Yinv= Wnk*Y ; % Twiddle factor matrix multiplied by Y% L=length...
dftidft1 clc clear all close all X=input( 'Enter the Input Sequence' ); N=input( 'Enter the Value of N such that N-point DFT is to be Calculated' ); % INPUTS ARE GIVEN % Y= fft(X,N) %DFT IS CALCULATED% L=length(Y); n=0:1:L-1; figure,plot(n,abs(Y)),title( 'Magnitude Response of DFT' ) figure, plot(n, angle(Y)), title( 'Phase Response of DFT' ) %MAGNITUDE and PHASERESPONSE OF DFT SIGNAL IS PLOTTED% Yinv=ifft(Y,N) %IDFT IS CALCULATED% figure,plot(n,abs(Yinv)),title( 'Magnitude Response of IDFT' ) figure, plot(n, angle(Yinv)), title( 'Phase Response of IDFT' ) %MAGNITUDE and PHASERESPONSE OF ORIGINAL SIGNAL IS PLOTTED% Error using input Cannot call INPUT from EVALC. Error in dftidft1 (line 5) X=input('Enter the Input Sequence'); Published with MATLAB® R2013b
In this blog we are willing to accumulate useful information related to the hot topic in market : Digital Signal Processing !! | Starting with very basics this blog would lead to you some interesting topics in DSP which will help you a lot !
Comments
Post a Comment