www.gusucode.com > signal 案例源码程序 matlab代码 > signal/CommonPeriodicWaveformsExample.m

    %% Common Periodic Waveforms
% The toolbox provides functions for generating widely used periodic
% waveforms:
%
% * |sawtooth| generates a sawtooth wave with peaks at $\pm1$ and a period
% of $2\pi$. An optional width parameter specifies a fractional multiple of
% $2\pi$ at which the signal maximum occurs.
% * |square| generates a square wave with a period of $2\pi$. An optional
% parameter specifies the _duty cycle_, the percent of the period for which
% the signal is positive.

% Copyright 2015 The MathWorks, Inc.


%%
% To generate 1.5 seconds of a 50 Hz sawtooth wave with a sample rate of 10
% kHz and plot 0.2 seconds of the generated waveform, use

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

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