A procedure for automatic phase alignment of training waveforms prior to computation of K-L basis functions is described. Two computer algorithms for accomplishing the phase alignment which have been developed and applied to electrocardiogram waveforms are discussed. One is a local maximum seeking algorithm which works well for waveforms which are already nearly aligned. The other, a global maximum seeking algorithm, has been successfully applied to highly misaligned sets of waveforms. Extension of the procedure to automatic frequency alignment is also discussed.