Waveforms

More complicated waveforms can also be made up from sine waves. In fact this is better than a more naive approach. Here is the naive approach to generating a square wave :

		octave:1> sq = [ones(1,400) -1*ones(1,400)] ;
		octave:2> sq = wave_cat (sq, 20) ;
		

A more correct approach using a sum of sines to avoid aliasing :

		octave:1 > f = (1:2:399) ./800;
		octave:2 > phase = zeros (size (f));
		octave:3 > mag = 1 ./ (1:2:399);
		octave:4 > plot ( sinegen (800, 1, f(1:10), phase(1:10), mag(1:10)))
		octave:5 > sq = sinegen (800, 1, f, phase, mag);
		octave:6 > sq = wave_cat (sq, 20) ;
		

A triangle wave :

		octave:89 > f = (1:2:399) ./800;
		octave:90 > phase = pi * wave_cat ([0 1], length (f)/2);
		octave:91 > mag = 1 ./ ((1:2:399).^ 2);
		octave:92 > plot ( sinegen (800, 1, f, phase, mag))
		

back.png next.png