1.正弦波
%% 清内存 关闭窗口 准备工作
clear
close all
clc
%% signal
% 三要素
A=5; %amplify
f=2; %Hz
w=2*pi*f; %rad/s
p=0; %rad
%采样
T=1; %s %观测时间
fs=20*f; %Hz %采样频率
d=1/fs; %s %采样间隔
t=-T/2:d:T/2; %离散时间t
s1=A*sin(w*t+p); %正弦信号
figure(1)
plot(t,s1);
xlabel('时间/s');
ylabel('幅度');
表达式:y = A sin(ωt + φ) + B
A:影响幅度
B:影响上下偏移
φ:初相位置
ω:角速度,w=2*pi*f;
t:离散时间
![](https://img-blog.csdnimg.cn/img_convert/1caae5bd8e3a1372a7cc440dfc992831.png)
2.方波
%% 清内存 关闭窗口 准备工作
clear
close all
clc
t=-2*pi/100:pi/500:2*pi/100;
y=square(2*pi*25*t,50);
plot(t,y);
xlabel('时间/s');
ylabel('幅度');
![](https://img-blog.csdnimg.cn/img_convert/fea2be00d60b4c9006e7e13824ec254f.png)
3.三角波
%% 清内存 关闭窗口 准备工作
clear
close all
clc
t=0:pi/180:2*pi;
y=sawtooth(5*t,0.5);
plot(t,y,'r'); % t为横坐标,y为纵坐标,'r' - 画红色线;
xlabel('时间/s');
ylabel('幅度');
![](https://img-blog.csdnimg.cn/img_convert/8d92fa95c32799550e5328e318ed9394.png)
4.随机信号
%% 清内存 关闭窗口 准备工作
clear
close all
clc
t=1:1:60;
N=length(t);
zaoshengY=rand(1,N);
plot(t,zaoshengY,'r');
xlabel('时间/s');
ylabel('幅度');
![](https://img-blog.csdnimg.cn/img_convert/a0046b1a21fbdf2ea94fd57b9cdd613e.png)