常见的周期性波形
Signal Processing Toolbox™ 提供可用来生成广泛使用的周期性波形的函数。
以 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])
以 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])
使用 dutycycle
函数验证方波的占空比是否为指定值。不带输出参量调用该函数来绘制波形、中间参考瞬时电平的位置、相关联的参考电平、状态电平以及相关联的状态上下边界。
dc = dutycycle(x,fs); dc = dc(1)
dc = 0.2500
dutycycle(x,fs); xlim([0 0.2])