> I'm having problems getting the plot to display in seconds rather than samples.
It looks like your t vector is in samples instead of seconds.
Fs = heartRate/60;
x = ecg(2700);
t = linspace(0, 15999, 16000)/Fs;
The actual sampling rate is 2700*Fs, not Fs. Try
t = linspace(0, 15999, 16000)/(2700*Fs);
Side question: How is the "heart rate" of the user determined for this function? Is it a given value used for generating ECG test signals?