Extending a waveform Apologies if this makes no sense or seems rather simple, I'm a Matlab newbie. 

Basically, I've got a .wav audio waveform which I am resampling to various different frequencies and then trimming the length to a second (44100 samples). However, when resampling to certain tones, such as the note C3 or A5, I'm not left with enough samples to trim the note to an acceptable length.

Obviously this means that the sample needs extending, which I've worked out can be done taking a sample period s1 to s2 and adding that onto the end as many times as is necessary. 

extendedSignal = x(1:s1-1);

for i = 1:4
    extendedSignal = vertcat(extendedSignal, x(s1:s2));
end

extendedSignal = vertcat(extendedSignal, x(s2:44100));


However, when it comes to finding a continuous period in which to sample, I cannot seem to find one for any note which does not sound like it is being repeated. Am I missing something really obvious?
Although it's not entirely clear to what you try to do (maybe there are better ways to accomplish your goal), I'll try to give some hints.

There exist "time stretching" techniques that can slow down a sample without changing its pitch, but they are not trivial to implement yourself. Some audio editors have plugins that support this.

As a poor man's implementation, if the sound has a single pitch, you can try something like the following (I've successfully used this in the past to extend a long, sung, single note):

First I cut the sound in three parts:

Sound -> | Begin | Middle | End |

Always cut at zero crossings.

Then, if you make "Middle" short enough, like around 0.1 seconds or so, you can repeat it a number of times times to stretch your sound a bit:

| Begin | Middle | Middle | Middle | Middle | Middle | Middle | End |