数字信号处理上机实验报告
2018年5月21日
M 2.2
1. 题目
The square wave and the sawtooth wave are two periodic sequences as sketched in figure P2.4.Using the function stem. The input data specified by the user are: desired length L of the sequence, peak value A, and the period N. For the square wave sequence an additional user-specified parameter is the duty cycle, which is the percent of the period for which the signal is positive. Using this program generate the first 100 samples of each of the above sequences with a sampling rate of 20 kHz ,a peak value of 7, a period of 13 ,and a duty cycle of 60% for the square wave.
2. 程序
clc ; close all;
f = 20000;%采样频率 L = 100*(1/f);%采样个数 A = 7;%最大值 N = 13;%周期
t = 0:1/20000:L-1/20000; %t=0:1:20;
y1 =(A * sawtooth(2*pi/N*f*t)); m =(A - max(y1))/2; y2 = m+y1; figure(1); subplot(2,1,1); stem (t,y2);
y3 = square(2*pi/13*20000*t,60); subplot(2,1,2) stem (t,y3);