% demo of FS constructions % Jonathan (Y) Stein % resolution and number of terms t = (1:1024)/512; N=15; % get Chinese gong sound from toolbox demos load('\matlab\toolbox\matlab\sounds\gong.mat'); gong=y; % sawtooth wave figure(1); set(1, 'Position', [ 5 200 390 350]); title('sawtooth'); figure(2); set(2, 'Position', [400 200 390 350]); 'SUM_i sin(2 pi i t) / i' y = zeros(size(t)); for i = 1:N x = sin(2*pi*i*t)/i ; y = y + x; figure(1); hold on ; plot ( t, x ) ; figure(2); plot ( t, y ) ; i pause ; end sound(gong,8192); pause; % square wave figure(3); set(3, 'Position', [ 5 200 390 350]); title('square wave'); figure(4); set(4, 'Position', [400 200 390 350]); 'SUM_{odd i} sin(2 pi i t) / i' y = zeros(size(t)); for i = 1:N j = 2*i-1; x = sin(2*pi*j*t)/j ; y = y + x; figure(3); hold on; plot ( t, x ) ; figure(4); plot ( t, y ) ; i pause ; end sound(gong,8192); pause; % triangular wave figure(5); set(5, 'Position', [ 5 200 390 350]); title('triangle wave'); figure(6); set(6, 'Position', [400 200 390 350]); 'SUM_{odd i} cos(2 pi i t) / i^2' y = zeros(size(t)); for i = 1:N j = 2*i-1; x = cos(2*pi*j*t)/(j*j) ; y = y + x; figure(5); hold on ; plot ( t, x ) ; figure(6); plot ( t, y ) ; i pause ; end sound(gong,8192); pause; % impulse figure(7); set(7, 'Position', [ 5 200 390 350]); title('impulse'); figure(8); set(8, 'Position', [400 200 390 350]); 'SUM_i cos(2 pi i t)' y = zeros(size(t)); for i = 1:N i x = cos(2*pi*i*t) ; y = y + x; figure(7); hold on ; plot ( t, x ) ; figure(8); plot ( t, y ) pause end sound(gong,8192);