I'm not sure how you are using the term "period" here. If you are talking about only the first 1 of the fundamental frequency which is 1 MHz here, then I think you want at least a few periods to do a spectral analysis even with a clean waveform. The resolution in the DFT (implemented by fft) depends on the number of samples. The more samples, the better the resolution.
In your case, it's easy to see that
gives you the initial waveform, so why not use this?
Fs = 1/1e-8;
d = fdesign.lowpass('Fp,Fst,Ap,Ast',1.2e6,1.4e6,0.5,60,Fs);
Hd = design(d,'butter');
xnew = x(1:2800);
y = filter(Hd,detrend(xnew,0));
ydft = fft(y);
freq = 0:Fs/length(y):Fs/2;
ydft = ydft(1:floor(length(y)/2)+1);
plot(freq./1e6,abs(ydft))
axis([0 10 0 max(abs(ydft))+20])
xlabel('MHz'); ylabel('Magnitude');
If you copy and paste the above code, it works fine.
Best Answer