Main Content

常见的周期性波形

Signal Processing Toolbox™ 提供可用来生成广泛使用的周期性波形的函数。

  • sawtooth 生成锯齿波,波峰在 ±1,周期为 2π。可选宽度参数以 2π 的小数倍来指定信号最大值出现的位置。

  • square 生成周期为 2π 的方波。可选参数指定占空比,即信号为正的周期的百分比。

以 10 kHz 的采样率生成 1.5 秒的 50 Hz 锯齿波。绘制 0.2 秒的生成波形。

fs = 10e3;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t);

plot(t,x)
axis([0 0.2 -1 1])

Figure contains an axes object. The axes object contains an object of type line.

以 10 kHz 的采样率生成 1.5 秒的 50 Hz 方波。指定 25% 的占空比。绘制 0.2 秒的生成波形。

fs = 10e3;
t = 0:1/fs:1.5;
x = square(2*pi*50*t,25);

plot(t,x)
axis([0 0.2 -1 1])

Figure contains an axes object. The axes object contains an object of type line.

使用 dutycycle 函数验证方波的占空比是否为指定值。不带输出参量调用该函数来绘制波形、中间参考瞬时电平的位置、相关联的参考电平、状态电平以及相关联的状态上下边界。

dc = dutycycle(x,fs);
dc = dc(1)
dc = 
0.2500
dutycycle(x,fs);
xlim([0 0.2])

Figure Duty Cycle Plot contains an axes object. The axes object with xlabel Time (seconds), ylabel Level (Volts) contains 9 objects of type line. One or more of the lines displays its values using only markers These objects represent signal, mid cross, upper boundary, upper state, lower boundary, mid reference, lower state.

另请参阅

| |