You could use only the first five frequencies, if you wanted an approximation. Reconstructing from less than all the available frequency components loses detail in the reconstruction. The reconstructed signal will be the size of the frequencies you used to reconstruct it. You can zero-pad the reconstructed signal out to the length of the original vector (I did not do that here), but you cannot recover the information you lost.
t = linspace(0, 1, 24);
x = (t >= 1/3) & (t <= 2/3);
y = fft(x);
ys1 = fftshift(y);
ys2 = fliplr(fftshift(ys1(8:18)));
xinv = ifft(ys2);
legend('Original Waveform', 'Reconstructed From First 5 Freqencies', 'Reconstructed From All Frequencies')