Professional Documents
Culture Documents
Compre
Compre
n1 = -5:8;
x1 = zeros(size(n1));
x1(n1 >= -5 & n1 < 0) = -3 * n1(n1 >= -5 & n1 < 0);
x1(n1 >= 1 & n1 <= 5) = 3 * n1(n1 >= 1 & n1 <= 5);
x1(n1 >= 6 & n1 <= 8) = 5;
figure;
Discrete FFT
t = 0:1/512:(1-1/512);
x = 4*cos(2*20*pi*t - pi/8) + 6*cos(2*40*pi*t + pi/6) + 10*cos(2*120*pi*t + pi/4);
N=512;
y = fft(x,N)
freq = 0:(N/2-1)
function[xofn,index]= impulsesignal(sindex,lindex,rindex)
index=[lindex:rindex];
xofn =[(index-sindex)==0];
end
if K > 1
titleText = 'Exponentially Increasing Sinusoidal Sequence';
elseif K < 1
titleText = 'Exponentially Decreasing Sinusoidal Sequence';
else
titleText = 'Sinusoidal Function';
end
subplot(1,2,1);
stem(n, x_n);
title(titleText);
xlabel('n');
ylabel('x2(n)');
grid on;
end
x = sin(2*pi*fm*t);
numM = ones(1,M);
denM = [M,zeros(1,M-1)];
[H,w] = freqz(numM, denM, N);
freq = (w/pi)*N/2;
m = abs(H);
subplot(3,1,2);
plot(freq,m);
xlim([0 fs/2]);
b = fir1(44,[0.3 0.6],hann(45))
n = 0:44
stem(n,b);
L = length(t);
n1 = 2^nextpow2(L)
[h,f] = freqz(b,1,n1,fs);
plot(f,20*log10(abs(h)));
str2double()
str2num()