
Need help to write a program to plot a magnitude response and phase response of a signal x (n) = a^n*u(n) .a) using loop b) using MATLAB command for DFT.
    9 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
Hi all,
Please suggest a code for a program to plot a magnitude response and phase response of a signal x (n) = a^n*u(n).
a) using loop b) using MATLAB command for DFT.
0 Kommentare
Akzeptierte Antwort
  Alberto
      
 am 5 Sep. 2014
        DFT is:

so you can make it by using loop or matlab FFT function directly, hope this help:
%%using loop
%a is a constant
clear
a=2;
N=100;
for k=1:N
    X(k)=0;
    for n=1:N  %this include u(n)
        x(n)=a.^n; 
        X(k)= X(k)+(x(n)*exp(-j*2*pi*(k-1)*(n-1)/N));
    end
end
subplot(2,1,1),plot(abs(X))  %magnitude
subplot(2,1,2),plot(angle(X)) %phase
%%using FFT
%a is a constant
clear
a=2;
N=100;
n=[1:1:N];
x=a.^n;
X=fftshift(fft(x),N);
subplot(2,1,1),plot(n,abs(X))  %magnitude
subplot(2,1,2),plot(n,angle(X)) %phase
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Digital Filter Analysis finden Sie in Help Center und File Exchange
			
	Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

