# I still get aliasing of my signal, even though I stay below the Nyquist frequency. What am I missing?

Thanks in advance for any help with my newbie question. I've been consulting quite a large number of resources in order to understand how I can create and playback a nice sawtooth without aliasing, but I feel something is really not clicking, since explanations I've been reading have only been confusing me further.

It's my understanding that aliasing should not occur if my signal does not contain any sinusoidal components above the Nyquist frequency. So, to be safe, I create a sawtooth using the following code:

            fs = 48000;
a = linspace(0,(fs/20),fs);
SinAudio = sin(2*pi*a+0.5*pi);

for i = 1:(length(amaxi)-1)
SawElement{i} = linspace(-1, 1, (amaxi(i+1)-amaxi(i)));
end

% Make first sawtooth element
Saw = linspace(0,1,amaxi(1));

% Concatenate rest of elements
for i = 1:length(SawElement)
Saw = [Saw, 0, SawElement{i}];
end


In this case, what I perceived as aliasing is apparent as a lot of clearly audible low frequencies, that sort of sound bubbly, especially when I sweep the signal.

So, the base frequency is way below my sampling frequency, and the way I concatenate the elements of the sawtooth, I take two samples to go from 1 to -1. Intuitively, I feel like this is where it goes wrong, because if you were to create a signal like that from individual sinusoids, you would need A LOT of harmonics, which would be why I get aliasing..

HOWEVER, there should be no more harmonics there than when I create a sine wave like this:

fs = 48000;
a = linspace(0,(fs/4),fs);
x = sin(2*pi*a+0.5*pi);


Which is a sinewave with a frequency of half the nyquist frequency, and therefor I wouldn't expect aliasing... I think?

So, my questions are: 1) Why does a generated signal with maximum frequency at half the nyquist rate still alias? 2) How do I create a bandlimited sawtooth or squarewave? I tried using wavetable synthesis, and although I haven't tested the resulting signal yet, I don't see how bandlimited wavetable synthesis would give me any different results from the two pieces of code I described above; ultimately, there's going to be a point where my signal goes from 1 to -1 over the course of 2 or 3 samples, no matter how I generate my signal..