MATLAB: I want to determine the magnitude and phase of 100kHz Sinusoidal in a given signal when the sampling rate is 15MHz and when the signal has 32768 samples.

digital signal processingfftfourier transformmathematicsMATLABsignal processing

the code I used is as follows. Around 100kHz. Phase changes from 160 degrees (@99.79kHz) to -18 degrees (@101.2kHz). How can I adjust settings to correctly add 100kHz frequency point instead of 99.79kHz and 101.2kHz?
FFT_V_in = 2*fft(DAQSig(2,:))/n;
FFT_V_in_mag = (abs(FFT_V_in));
FFT_V_in_phase = angle(FFT_V_in);
fs=15000000
f = (0:n-1)*fs/n;
subplot(2,1,1)
plot(f,1000*FFT_V_in_mag)
ylabel('V_{in} (mV)')
ytickformat('%.2f')
title('Magnitude')
subplot(2,1,2)
plot(f,FFT_V_in_phase*180/pi)
ytickformat('%.2f')
ylabel('V_{in} (degree)')
title('Phase')
The output is as follows

Best Answer

When you do an FFT, you basically assign magnitudes to each frequency. The frequency points are usually called bins and are determined by your sampling frequency and length of your signal. For instance, if your sampling frequency is 1000 Hz and you have 5000 samples, then the frequencies in the fft will be integer multiples of 1000/5000 = 0.2 Hz.
So to answer your question, if you were to adjust your Fs/N ratio (sampling rate/ length of the signal) to be 1, 0.1,10,100, you will get 100 Hz in your data instead of 99.76 Hz. This is most easily done by adjusting the length of your data rather than changing the sampling frequency.
For your data, you can use the first 30000 samples instead of 32768 and it should give you what you need (data at every 500 Hz, including 100 kHz).
Related Question