%% 50 Hz Triangle Wave
% Generate 10 periods of a triangle wave with a fundamental frequency of 50 Hz. The sample rate is 1 kHz.

T = 10*(1/50);

fs = 1000;
t = 0:1/fs:T-1/fs;

x = sawtooth(2*pi*50*t,1/2);

plot(t,x)
grid on

%
% Plot the power spectrum of the wave.

pspectrum(x,fs,'Leakage',0.91)

% Copyright 2018 The MathWorks, Inc.