Matlab產生離散信號
常見離散信號
沖擊信號
n = -5:5;
x = n == 0;% 當n為0時,x的值為1
stem(n, x, 'filled');
axis([-5 5 0 1.1*max(x)]);%規定坐標軸的范圍
xlabel('時間(n)');ylabel('幅度(n)');

沖擊信號
階躍信號
n = -2:8;
x = n >= 0; % 當n大於等與零時,其值為1
stem(n, x, 'filled');
axis([-4, 4, 0, 1.1*max(x)]);
title('階躍信號');
xlabel('時間(n)');ylabel('幅度(n)');

階躍信號
實指數序列
n1=-10; n2=10;
a1=0.5; a2=2;
na1=n1:0;
x1 = a1.^na1;
na2 = 0:n2;
x2 = a2.^na2;
subplot(2,2,1);
plot(na1,x1);
title('實指數原信號(a<1)');
subplot(2,2,3);
stem(na1,x1,'filled');
title('實指數序列(a<1)');
subplot(2,2,2);
plot(na2,x2);
title('實指數原信號(a>1)');
subplot(2,2,4);
stem(na2,x2,'filled');
title('實指數序列(a>1)');

實數序列
復指數序列

n = -10:0.2:10;
x = exp((-0.2+1j*0.6*pi)*n);
subplot(2,2,1), plot(n, real(x));% real畫出實部
subplot(2,2,3), stem(n, real(x), 'filled');
subplot(2,2,2), plot(n, imag(x)); % imag畫出虛部
subplot(2,2,4), stem(n, imag(x), 'filled');

復指數信號
隨機信號
tn=0:0.2:15;
N=length(tn);
x=rand(1,N);
subplot(2,1,1);
plot(tn,x);
tn=0:0.5:15;
N=length(tn);
y=rand(1,N);
subplot(2,1,2);
stem(tn,y);

隨機信號