% empty out final sound vector snd = []; % define low-quality sampling rate (telephone quality of 8000 samples per % second) r = 8000; % define length of each tone l = 0.01; % in a loop going from frequency 1000Hz to frequency 2000Hz in increments % of 100Hz, build tones with different periods % the concatenation of these tones produces a sound with increasing tones for f=1000:100:2000 snd=[snd, sin(2 * pi * f / r * [0:r * l])]; end % reverse of above: produce a final sound with decreasing tones for f=2000:-100:1000 snd=[snd, sin(2 * pi * f / r * [0:r * l])]; end % concatenate a few times to produce siren effect snd=[snd,snd,snd,snd,snd]; % play back sound wavplay(snd, r);