Hi thereb, the sine wave is right there, but the problem is that after FFTing the your y data, YfreqD contains half the samples than the original. When calculating the iFFT, that length is kept and plot(t1,B) plots half the original data.
You can try plot like this to see the points you are plotting in each case:
You can add a higher sampling rate at the beginning of your code and your figure(3) will appear like a less "straight" sine wave.
fo = 4;
Fs = 200;
Ts = 1/Fs;
t = 0:Ts:1-Ts;
n = length(t);
y = sin(2*pi*fo*t);
[YfreqD,freqRng] = positiveFFT(y,Fs);
B = ifft(YfreqD)*length(y);
t1 = (0:(1-Ts)/(length(B)-1):1-Ts);