%連續信号
%機關階躍信号
clc;
clear;
t=-1:0.01:4;
ft=(t>=0);
plot(t,ft);
axis([-1,4,-0.2,1.2]);
grid on;
%指數信号
clc;
clear;
t=0:0.01:6;
ft=6*exp(-1*t);
plot(t,ft);
grid on;
%正弦函數
clc;
clear;
f0=6;
w0=2*pi*f0;
t=0:0.001:1;
ft=4*sin(w0*t+pi/5);
plot(t,ft);
grid on;
%矩形脈沖信号
clc;
clear;
t=-3:0.01:3;
ft=2*rectpuls(t,3);
plot(t,ft);
axis([-3,3,-0.5,2.5]);
grid on;
%周期方波
clc;
clear;
f0=5;
t=0:0.001:1;
w0=2*pi*f0;
ft=square(w0*t,50);
plot(t,ft);
axis([0,1,-1.5,1.5]);
grid on;
%抽樣函數
clc;
clear;
t=-20:0.001:20;
ft=sinc(t/pi);
plot(t,ft);
grid on;
%離散信号
%機關脈沖序列
clc;
clear;
k=-5:5;
fk=[zeros(1,5),1,zeros(1,5)];
stem(k,fk);
grid on;
%機關階躍序列
clc;
clear;
k=-5:10;
fk=[zeros(1,5),ones(1,11)];
stem(k,fk);
grid on;
%指數序列
clc;
clear;
k=-5:5;
fk=0.6*2.^k;
stem(k,fk);
grid on;
%正弦序列
clc;
clear;
k=-8:8;
omega=pi/4;
phi=pi/3;
fk=2*sin(omega*k+phi);
stem(k,fk);
grid on;
%離散周期方波
clc;
clear;
omega=pi/3;
k=-9:9;
x=square(omega*k,50);
stem(k,x);
grid on;
%白噪聲序列
N=50;
k=0:N-1;
fk=rand(1,N);
stem(k,fk);
grid on;
%練習
clc;
clear;
t=0:0.01:5;
ft=10*exp(-1*t)-5*exp(-2*t);
plot(t,ft);
grid on;
clc;
clear;
t=0:0.0001:0.2;
ft=cos(100*t)+cos(3000*t);
plot(t,ft);
grid on;
clc;
clear;
k=-5:5;
fk=[zeros(1,6),1,zeros(1,4)];
stem(k,fk);
grid on;
clc;
clear;
k=-5:10;
fk=5*(0.8.^k).*cos(0.9*pi*k);%這裡向量和向量相乘要用.*
stem(k,fk);
grid on;
%機關沖激信号
t=-5:0.01:5;
cjy=0*(t>=-5&t<0)+1*(t==3)+0*(t>0&t<=5);
plot(t,cjy)
信号與系統實驗--基本連續和離散信号的表示