# How to read off power at different frequencies

In MATLAB, consider a signal y and its Fourier transform Y:

y = A .* sin(2*pi*f_c*t + Phi);
Y = 10*log(abs(fftshift(fft(y))) / length(y));


Now, I plot the signal and its spectrum:

figure
subplot(2,1,1)
plot(t,y)
subplot(2,1,2)
plot(t,Y)


my question: what exactly did I plot in the second subplot? I know my $x$-axis gives frequency in $\textrm{Hz}$. But what does the $y$-axis give? I want to be able to read off the power of my signal at different frequencies - if possible in $\textrm{dBm}$. Since my signal-amplitude A is used to define y and not its power, I am unsure of what my $y$-axis yields.

I know my x-axis gives frequency in Hz.

That is not the case.

A DFT is a mathematical transform between discrete signals in time and frequency domain. Just as as the number of your sample doesn't give you time in seconds, the number of the DFT bin doesn't give you frequency in Hertz.

Instead, the number of the sample gives you time in "sampling intervals $T$", and thus, the bin number in the $N$-point DFT gives you frequency in "Nyquist rate fractions" $\frac {T^-1}N = \frac{f_{sample}}N$, whereby you need to pay attention – the DFT should be understood as something that shows you both negative and positive frequencies, so therange is $-\frac{f_{sample}}2$, to $+\frac{f_{sample}}2$ (for odd and even lengths, take care of the boundaries when calculating what the frequencies of the DFT bases are). The zeroth DFT base is always the average/sum/DC of the signal.

if possible in dBm.

Not possible, unless you know the proportionality between your digital input signal to physical power, ie. you've calibrated your measurement setup and know which power a digital $1+0j$ has. Then: Parseval's theorem is your friend.

Note that the DFT is nothing but a linear operator – a matrix that maps $\mathbb C^N\mapsto \mathbb C^N$; the question how to interpret complex frequency domain values is absolutely up to your understanding of your system. Sometimes, the values' magnitude squares can be interpreted as estimate for the Power Spectral Density at the frequency of the bin – at other times, that is not the case (especially if you don't know whether your signal is weak-sense stationary).

Sometimes, the bin of a DFT of a system is an impulse (ask a physicist about the meaning of the Fourier transform for solid state electronics), sometimes it's something like a pseudo-angle (ask an antenna designer), sometimes, it's proportional to speed of something (ask a radar engineer), sometimes, it's really just that — a complex, $N$-dimensional vector, that has no physical significance.

I'd like to quoute:

One can Fourier transform anything—often meaningfully.
~John Tukey

• thx for your help! Let me try to understand: I am sampling my signal with frequency $f_s$. The time-vector is $t = 1:1/f_s:T$, time duration is $T = 1e-9$ and $f_s = 1e12$. This should yield $N = f_s*T$ samples. Hz means cycles per second, right? The unit of the sampling frequency $f_s$ is samples per second (I think). So I believe I have to determine the number of samples per cycle in order to get frequency in Hz. I don't think I understood your answer in this context. I have read that the "Nyquist frequency" = $f_s/2$. For some reason my spectrum goes from $-f_s/2$ to $f_s/2$.
– user25356
Dec 21 '16 at 15:38
• Also: I know $P = A^2/2$ is valid for my signal y. The Fourier Transform has transformed my signal y from time domain into frequency domain. In order to be able to read off power from my spectrum, does the given equation mean I can just square my spectrum and divide by 2 to yield P in frequency domain?
– user25356
Dec 21 '16 at 15:42
• you did not say "unit of axis", but "the $x$ axis gives me Hertz" (which it doesn't. It can only give you the bin number). Dec 21 '16 at 15:43
• Nyquist frequency is not, in general $\frac{f_s}2$. That's simply not true in the general case! It's the unambiguous range for real-valued signals, whose spectrum is symmetrical to f=0 Dec 21 '16 at 15:44
• and regarding your power relation: Parseval's theorem is your friend, and the Fourier transform is linear. Again, what the square of the value, the absolute of the value, the complex value itself of your DFT means is your interpretation of a physical system. Dec 21 '16 at 15:46