1
$\begingroup$

I am doing simulation of FMCW radar. I am applying signal processing chain on raw radar data. Here in the code below, I am taking fft of data and plotting it. Moreover, I am doing zero padding by multiplying the signal length by 1000. I should be getting beat frequency at 2.020 MHz instead I am getting at 2.019MHz. There is something little probelem but I do not know what.

Is it the correct way for Zero padding? Moreover, am I defining frequency axes correctly? Thanks everyone in advance

% second-order butterworth
[b, a] = butter(2, [w1 w2], 'bandpass');


load('fb2030');                                   % loading the data
x = fb2030(30,:);
% filtering
y_filt = filter(b,a,x);                           % filtering the received signal
nfft = length(y_filt)*1000;                       %%%% Zero Padding
res = fft(y_filt,nfft)/ nfft;                     % normalizing the fft


f = fs/2*linspace(0,1,nfft/2+1);                  % choosing correct frequency axes
res = res(1:nfft/2+1);                            % amplitude of fft(taking the half length of nfft)
figure,plot(f,2*abs(res));
xlabel('Frequency in MHz');ylabel('amp')
$\endgroup$
  • $\begingroup$ Nothing looks obviously wrong. You should elaborate on "not getting the desired output." $\endgroup$ – Jason R Aug 31 '15 at 12:10
  • $\begingroup$ Thanks Jason for your answer. I mean, I am applying fft on radar data. At the end, I shoud be getting beat frequency at 2.020MHz instead I am getting at 2.019MHz. Therefore, i am thinking that may be I am applying zero padding wrong or defining wrong frequency axes. $\endgroup$ – Urban_Yogi Aug 31 '15 at 13:20
  • $\begingroup$ @Urban_Yogi I think you should include this info into your question. This will help giving a better answer to your question. $\endgroup$ – Gilles Aug 31 '15 at 14:01
  • $\begingroup$ Done @ Gilles. Thansk for your comment. $\endgroup$ – Urban_Yogi Aug 31 '15 at 14:32
1
$\begingroup$

This line seems suspicious to me:

f = fs/2*linspace(0,1,nfft/2+1);  

Your frequency bins should be:

$$f_k = \frac{f_s}{\tt nfft} k$$

so

$$ \begin{array}{rcl} f_{{\tt nfft}/2 + 1} &=& \frac{f_s}{\tt nfft} ({\tt nfft}/2 + 1)\\ &=& \frac{f_s}{2} + \frac{f_s}{\tt nfft} \end{array}$$

whereas your linspace setting has it mapping to just $\frac{f_s}{2}$.

$\endgroup$
  • $\begingroup$ Or you meant $f_{{\tt nfft}/2 + 1} = \frac{f_s}{2} + \frac{f_s}{\tt nfft}$ ? And I think the choice of linspace is on purpose so as to only have a single side amplitude spectrum. $\endgroup$ – Gilles Aug 31 '15 at 15:03
  • $\begingroup$ ahh ok. let me try. Thanks for your answer Peter K. $\endgroup$ – Urban_Yogi Aug 31 '15 at 15:04
  • $\begingroup$ @Gilles: Yes, I have corrected my typo. Linspace is OK, but the range is wrong. And the range being wrong will mean the frequencies being plotted are wrong. $\endgroup$ – Peter K. Aug 31 '15 at 15:05
  • $\begingroup$ @PeterK. The remaining range from $\frac{f_s}{2}$ to $f_s$ is an image of what is already from $0$ to $\frac{f_s}{2}$. I don't think this will help solve his problem. $\endgroup$ – Gilles Aug 31 '15 at 15:11
  • $\begingroup$ That's the trouble: He's NOT doing 0 to $f_s/2$. He's doing 0 to $f_s/2 + f_s/{\tt nfft}$. So he's including part of the range from $f_s/2$ to $f_s$ in what he thinks is 0 to $f_s/2$. $\endgroup$ – Peter K. Aug 31 '15 at 16:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.