Understanding Power Spectral Density and the Power Spectrum

MATLAB
28 Feb 202420:43

Summary

TLDRThe video explains how to interpret and scale a Fast Fourier Transform (FFT) to gain meaningful insights about a time domain signal. It covers converting an FFT into amplitude, power, and power spectral density representations. The choice of representation depends on the analysis goal and signal characteristics. Key factors are using a rectangular window, ensuring a stationary signal, and accounting for spectral leakage. With the right approach, the FFT can reveal a signal's dominant frequencies and power spectrum. However, broadband signals require looking at power spectral density. Overall, matching the FFT analysis technique to the signal and end goal enables gaining accurate, physically meaningful insights.

Takeaways

  • 😀 The FFT transforms a time signal into a vector of complex numbers representing the signal's phase and magnitude at different frequencies.
  • 👍 Scaling the FFT properly is key to understanding time domain signal properties from the frequency domain.
  • 🤔 Choosing how to scale the FFT depends on your analysis goal - amplitude, power, power spectral density etc.
  • 💡 Taking the absolute FFT value divided by N gives the amplitude. Squaring that result gives the power.
  • ⚠️ Those equations only hold for rectangular windows on stationary, discrete spectra signals.
  • 🔍 The power spectrum shows power of dominant sine waves. The power spectral density works better for broadband signals.
  • 😕 Using the wrong FFT scaling leads to misleading results about time domain properties.
  • 📈 Longer FFT windows reduce spectral leakage but limit frequency resolution.
  • 🌄 The periodogram function handles windowing and scaling automatically.
  • 💯 Understanding signal characteristics and analysis goals allows proper interpretation of FFT results.

Q & A

  • What is the purpose of doing spectral analysis?

    -The purpose is to understand quantitative properties of the signal in the frequency domain, such as the amplitude of sine waves at particular frequencies. The analysis method depends on your specific goal.

  • Why do we divide the FFT by N to get the amplitude?

    -Dividing by N gives us the average amplitude across the window. This works because of the mathematical derivation of the discrete Fourier transform and properties of sine waves.

  • When can we use the power spectrum equations for amplitude and power?

    -The equations are only valid when using a rectangular window, the signal is stationary within the window, and the signal has a discrete frequency spectrum.

  • How does window size affect the power spectrum?

    -A longer window reduces spectral leakage but also reduces frequency resolution. Windowing affects amplitude and power calculations.

  • What is spectral leakage and how can it be reduced?

    -Spectral leakage occurs when the signal period is not an integer multiple of the window length. It can be reduced by using a longer window or applying a non-rectangular window.

  • What is power spectral density and when should it be used?

    -Power spectral density normalizes the power spectrum. It should be used for signals with a continuous frequency spectrum rather than discrete spectral components.

  • How do you calculate the equivalent noise bandwidth?

    -The equation squares each window term, sums them, multiplies by the sample rate, and divides by the sum of window terms squared.

  • What does the power spectrum of a window represent?

    -It shows the attenuation of nearby frequencies that will blend together and contribute to each frequency sample.

  • Why can't power be accurately calculated when frequencies are too close?

    -Too close frequencies merge into a single peak that represents their combined power rather than individual power.

  • How can the periodogram function be used?

    -The periodogram function conveniently outputs the power spectrum or power spectral density and handles window normalization automatically.

Outlines

00:00

🔍 Understanding FFT Scaling for Signal Analysis

This segment introduces the concept of Fast Fourier Transform (FFT) scaling and its significance in signal analysis. It begins with a primer on FFT and its role in transforming a time-domain signal into a frequency-domain representation, consisting of complex numbers that embody both magnitude and phase of the signal's frequencies. The video addresses common confusions regarding the scaling of FFT outputs to derive meaningful information such as amplitude, power, and power spectral density. It emphasizes the importance of choosing the correct scaling approach based on the analytical goal, whether it be identifying frequency content or quantifying specific signal properties in terms of physical quantities. The explanation includes a practical demonstration using MATLAB, illustrating how to convert FFT results into one-sided amplitude and power spectra, thereby making the data relatable to physical aspects of the signal.

05:04

📐 Detailed Analysis of FFT Amplitude and Power Calculations

In this part, the video delves into the mathematical rationale behind FFT amplitude and power calculations, highlighting the importance of dividing by the total number of samples (N) for accurate measurement. It provides a step-by-step explanation of how FFT, fundamentally equivalent to the Discrete Fourier Transform (DFT), processes a signal to yield frequency domain coefficients. The discussion includes the mathematical derivation showing how the summation of sine and cosine products underpins the amplitude calculation, emphasizing the halving of amplitude due to its distribution across positive and negative frequencies. This section concludes with the method of obtaining one-sided power spectrum by squaring the amplitude and adjusting for the number of samples, demonstrating these concepts through MATLAB examples.

10:05

🚀 Mitigating Spectral Leakage and Understanding Windowing Effects

This segment explores the concept of spectral leakage and its mitigation through windowing techniques. It introduces the rectangular window as the simplest form of windowing, where signal samples within the window are unmodified, and explains how non-integer multiple frequencies of the window length can lead to spectral leakage. This leakage spreads signal energy across neighboring frequency bins, potentially distorting the analysis. The video discusses the use of non-rectangular windows, like the Hamming window, to attenuate signal edges and reduce leakage, albeit at the cost of resolution. It underscores the critical role of window choice in FFT analysis, affecting amplitude and power measurements, and demonstrates how MATLAB's periodogram function can accommodate different windows to produce accurate power spectra.

15:07

📊 Analyzing Power Spectral Density and Its Implications

The final part of the video focuses on power spectral density (PSD) and its significance in analyzing signals with continuous frequency spectra. It illustrates how discrete sine wave signals can be accurately analyzed for power using FFT, but when frequencies are too close or the signal is broadband, the analysis becomes more complex. The video explains how power from multiple frequencies contributes to the total in such cases, making PSD a more appropriate metric since it represents power per frequency band. It concludes with a practical MATLAB demonstration on calculating PSD by normalizing the power spectrum with the equivalent noise bandwidth, offering insights into how different types of signals require different analytical approaches to accurately reflect their physical properties.

20:09

📝 Conclusion: Choosing the Right Tool for Signal Analysis

The concluding segment emphasizes the importance of understanding the signal and the analytical objective when choosing between amplitude, power spectrum, and PSD for signal analysis. It reminds viewers that while mathematical tools can provide various views of the signal, connecting these analyses to physical properties requires careful consideration of the signal characteristics. The video encourages further exploration of FFT and DFT through additional resources, urging viewers to subscribe for more insightful content on signal processing and other topics. It positions the discussed concepts as foundational knowledge for effective signal analysis, underlining the utility of MATLAB in applying these principles.

Mindmap

Keywords

💡FFT (Fast Fourier Transform)

The FFT is a mathematical algorithm that computes the Discrete Fourier Transform (DFT) of a sequence, or its inverse, efficiently. In the context of the video, FFT is used to analyze the frequencies contained within a time-domain signal by converting it into a vector of complex numbers, representing the signal's magnitude and phase across different frequencies. The FFT is a fundamental tool in spectral analysis, allowing the detection of different frequency components within a signal, which is crucial for understanding its characteristics.

💡Magnitude

In the context of FFT analysis, magnitude refers to the size or strength of a frequency component within a signal, obtained by taking the absolute value of the FFT output. The video explains that analyzing the magnitude of the FFT, especially in a one-sided spectrum, helps identify the presence and relative strength of different frequencies in a time-domain signal. For example, the magnitude can reveal dominant frequencies or noise within a signal, providing insights into its behavior or composition.

💡Phase

Phase in the context of FFT represents the angle of the complex numbers resulting from the FFT, indicating the shift or displacement of the sinusoidal components of the signal relative to a reference point. The video mentions that in many practical applications, the phase information might be disregarded when only the magnitude of the frequencies is of interest, simplifying the analysis to focus on the strength of the frequency components.

💡One-sided Spectrum

A one-sided spectrum displays only the positive half of the frequency spectrum obtained from the FFT, which is sufficient for real-valued time-domain signals since the negative frequencies mirror the positive ones. The video highlights this concept by explaining that in many cases, focusing on the one-sided spectrum simplifies the analysis without losing meaningful information, as the negative side offers no additional insight for such signals.

💡Amplitude

Amplitude in the context of FFT analysis refers to the actual height or strength of a sinusoidal component within a signal, measured from its equilibrium point. The video elaborates on how to convert the FFT output into meaningful amplitude information by scaling the absolute values of the FFT by the number of samples, and then adjusting for a one-sided spectrum. This process allows the determination of the physical amplitudes of sinusoidal components within the original time-domain signal.

💡Power Spectrum

The power spectrum is a representation of the signal's power content distributed over the frequency domain. The video describes how to derive the power spectrum from the FFT by squaring its magnitude (to get power) and scaling appropriately. The power spectrum is particularly useful for analyzing the energy distribution across different frequencies within a signal, providing insights into its power characteristics at specific frequencies.

💡Spectral Leakage

Spectral leakage occurs when the discrete sampling of a signal causes the spread of signal energy across adjacent frequencies, particularly when the signal's frequency components do not align perfectly with the FFT bin frequencies. The video discusses spectral leakage in the context of windowing, explaining how it can distort the true frequency content of a signal and how applying different window functions can mitigate its effects.

💡Windowing

Windowing is a technique used in FFT analysis to manage the effects of analyzing a finite segment of a signal, often by applying a specific function to taper the signal at its boundaries. The video explains that while a rectangular window (which leaves the signal unmodified within the window) is straightforward, other window types like Hamming or Blackman can reduce spectral leakage by attenuating the signal edges, albeit at the cost of resolution.

💡Stationarity

A stationary signal is one whose statistical properties, such as mean and variance, do not change over time. The video emphasizes the importance of stationarity in FFT analysis, as non-stationary signals can lead to misleading average power or amplitude readings due to fluctuations within the windowed segment of the signal.

💡Power Spectral Density (PSD)

Power Spectral Density is a measure of a signal's power content per unit frequency, providing a detailed view of how power is distributed across frequencies. The video explains how to obtain PSD from the FFT by normalizing the power spectrum with respect to the frequency resolution, making it a valuable tool for analyzing signals with continuous spectra or for comparing power distribution across different frequency bands.

Highlights

Clarification on scaling an FFT for understanding time domain signal properties.

Differentiation between FFT amplitude, power, and power spectral density representations.

Discussion on the relevance of selecting specific FFT representations based on analysis goals.

Explanation of how to derive amplitude from an FFT.

Method to obtain amplitude of a sine wave from the FFT by dividing by total number of samples.

Demonstration of amplitude extraction from FFT using MATLAB.

Derivation of FFT amplitude scaling factor based on discrete Fourier transform.

Explanation of obtaining power from a signal's FFT.

Introduction of the concept of a one-sided power spectrum.

Illustration of converting FFT to one-sided power spectrum in MATLAB.

Discussion on the importance of using a rectangular window for accurate FFT results.

Explanation of spectral leakage and its mitigation techniques.

Requirement of signal stationarity for valid FFT analysis.

Impact of discrete versus continuous frequency spectra on FFT analysis.

Derivation and application of power spectral density from FFT.

Conclusion emphasizing the necessity of understanding signal characteristics for appropriate FFT analysis.

Transcripts

play00:00

In this video, we're going to look

play00:01

at how to get meaningful information from a fast Fourier

play00:04

transform, from an FFT.

play00:07

And I want to clear up what I see

play00:09

is a lot of confusion on how to scale an FFT in a way that

play00:12

provides an understanding of the properties of the time domain

play00:15

signal.

play00:16

Specifically, I want to cover how

play00:18

we go from an FFT to amplitude and to power and to power

play00:25

spectral density.

play00:26

And I want to talk about why we may choose

play00:28

one representation over another and the scenarios

play00:31

in which they are valid.

play00:33

I think this will be useful.

play00:34

So I hope you stick around for it.

play00:36

I'm Brian, and welcome to a MATLAB Tech Talk.

play00:40

If you don't know what an FFT is,

play00:42

then I recommend watching my video on it,

play00:44

that I've linked to below.

play00:46

But for right now, all that you really need to know

play00:49

is that when you take an FFT of a signal,

play00:51

it returns a vector of complex numbers.

play00:54

And here, I'm just plotting the real and imaginary parts

play00:57

of an FFT for time signal xn.

play01:00

And these numbers represent the phase

play01:02

and the magnitude of the frequencies

play01:04

that exist within x sub n.

play01:06

And in that video, we covered how, in some cases,

play01:09

we aren't concerned with phase.

play01:11

So we just look at the magnitude by taking

play01:13

the absolute value of the FFT.

play01:15

And then when dealing with real time signals,

play01:18

the magnitude of the FFT is duplicated between the positive

play01:23

and the negative frequencies.

play01:24

And since the information is the exact same,

play01:27

we can choose to only look at the positive frequencies,

play01:30

a so-called one-sided FFT.

play01:32

And this is where we left that video, with a one-sided plot

play01:37

of magnitude, versus frequency.

play01:40

Now, how can we use this information

play01:43

to understand something about the time signal?

play01:46

And when it comes to spectral analysis,

play01:48

the question you have to start with is, why are you doing it?

play01:51

What are you hoping to learn by analyzing a signal

play01:55

in the frequency domain?

play01:56

And the reason that this is an important question

play01:58

is because the tool that you use to do your spectral analysis

play02:01

depends on your goal.

play02:03

And in the case of this video, how you manipulate

play02:06

the FFT depends on your goal.

play02:09

For example, if all you want to know

play02:11

is where frequency content exists

play02:13

in the signal relative to each other,

play02:15

then this magnitude plot is sufficient.

play02:18

I mean, I can tell that there is a strong frequency

play02:21

component at 110 hertz, and there

play02:23

is a weaker, but still obvious component at 100 hertz.

play02:27

And this level of analysis might be

play02:29

good for figuring out if there's a 60-hertz noise in a signal

play02:34

or maybe, what the natural frequency is

play02:36

of a structure that's vibrating.

play02:38

So it's pretty cool that you can get that information

play02:42

from the magnitude.

play02:43

But the downside of this plot is that this value on the y-axis

play02:48

isn't a quantity that relates to some physical property

play02:51

of the time signal.

play02:52

So what if you do want to know something

play02:54

quantitative about the signal?

play02:56

Say you want to know the amplitude of a sine wave

play02:59

at a particular frequency.

play03:01

Well, I'm going to spoil it for you.

play03:03

This is how you do it.

play03:04

You take the absolute value of the FFT

play03:07

and then divide by capital N, which

play03:09

is the total number of samples in the signal.

play03:12

This produces amplitude, but it's

play03:14

split, with half of the amplitude being captured

play03:17

in the positive frequencies and the other half

play03:19

in the negative frequencies.

play03:20

And so if we just want to look at a one-sided spectrum,

play03:23

we ignore the negative frequencies and double

play03:26

the values for every positive frequency

play03:29

except for the DC term, which is 0 hertz, and the Nyquist

play03:33

frequency.

play03:35

And we can go over to MATLAB and see that this works.

play03:38

It actually returns the amplitude of a sine wave.

play03:41

I have a time signal with two sine waves

play03:43

with amplitudes 1 and 4.

play03:45

And then I take the absolute value of the FFT,

play03:48

divide by the number of samples, and then look at just one side

play03:52

and double it, except for the DC and Nyquist.

play03:55

And when I plot this spectrum, the y-axis

play03:58

now shows amplitudes of 1 and 4, so perfect.

play04:03

But the question might be, is why are we dividing by N?

play04:07

I mean, why does this work, in the first place?

play04:09

Well, let's quickly walk through an explanation.

play04:13

OK, so the FFT is mathematically equivalent

play04:16

to the discrete Fourier transform, which

play04:18

says that we start with a time signal xn,

play04:21

multiply it by a correlating signal, which

play04:23

is this exponential here, and then sum over

play04:26

all of the samples.

play04:28

And this produces the frequency domain coefficients xk.

play04:32

Also, e raised to an imaginary number

play04:35

is just a function of cosine and sine.

play04:38

All right, so now let's say that the time signal is just

play04:40

a sine wave with amplitude A. And it

play04:42

doesn't matter what frequency it's at, so I'm just

play04:44

going to put a dot in here.

play04:46

And if we plug this into the DFT,

play04:48

we get that xk is equal to the amplitude A times the summation

play04:53

over all of the samples of sine times

play04:55

cosine minus i times sine squared.

play04:59

And sine times cosine produces another sinusoid.

play05:03

And so the summation over one period is 0.

play05:07

It cancels each other out.

play05:08

So no matter how long the signal is,

play05:11

the summation will always be close to 0l.

play05:14

And therefore, this first component

play05:16

doesn't contribute much to the summation.

play05:18

Sine squared, on the other hand, looks like this,

play05:21

like a sinusoid that goes between 0 and 1.

play05:24

And since this is discrete, we're sampling it n times.

play05:29

Now, the more samples we have, the larger this summation

play05:31

will be.

play05:32

However, if we add up all of the samples

play05:35

and then divide by the number of samples,

play05:37

this will give us the average height

play05:40

of the sine squared function, right?

play05:42

I mean, if you add up 10 numbers and divide by 10,

play05:45

you get the average value.

play05:46

Well, the average value for sine squared is 1/2.

play05:52

So if we go back to the above equation,

play05:54

we can divide xk by N. And now, this whole summation

play05:58

is 0 for the first component still.

play06:00

But it's 1/2 i for the second component,

play06:03

since it's just the average height of sine squared.

play06:06

Now we're taking the absolute value

play06:08

of x of k, which gives us the magnitude of the FFT.

play06:12

And that is equal to 1/2 the amplitude.

play06:15

And again, the reason that it's in half here

play06:18

is because the amplitude is split

play06:19

between the positive and negative frequencies.

play06:21

But if we're just looking at a one-sided FFT,

play06:24

then we're multiplying this by 2.

play06:27

And we're left with amplitude.

play06:30

Now, I just want to note that if our original time signal had

play06:33

a phase shift to it, this all still works out mathematically.

play06:36

I just did a 0 phase sinusoid to make it easier to follow.

play06:40

But I think overall, this is pretty cool,

play06:42

that we can find the amplitude of a sinusoid

play06:45

simply by taking the FFT and scaling it.

play06:49

All right, so that's amplitude.

play06:50

But what if we want to know power

play06:52

at a particular frequency?

play06:53

Well, the average power of a sinusoid

play06:55

is just its amplitude squared over 2.

play06:58

And since we know that the absolute value

play07:00

of the FFT divided by N gives us the amplitude over 2,

play07:05

then the easiest thing we can do is just square that value.

play07:08

And this is the two-sided power spectrum,

play07:10

since the power is split between negative and positive

play07:13

frequencies.

play07:14

So to get the one-sided power spectrum, we multiply it by 2.

play07:18

And this is how we go from the FFT

play07:21

to the one-sided power spectrum.

play07:24

So let's go back over to MATLAB and see

play07:27

how we can implement this.

play07:29

This, by the way, is the same script as before.

play07:31

So we're working with the same two-sine wave signal.

play07:34

And I'm just going to scroll down past Amplitude

play07:36

and get to the Power section.

play07:38

So here, I'm taking the absolute value of the FFT,

play07:41

then squaring it and dividing by N squared.

play07:45

And then to get a one-sided power spectrum,

play07:47

we ignore the negative frequencies

play07:49

and double the positive frequencies,

play07:51

again, except for DC and Nyquist.

play07:54

Now, the plot looks like this, with powers of 1/2 and 8,

play07:59

which correspond to the amplitudes 1 and 4,

play08:02

respectively.

play08:03

So it all works out nicely.

play08:06

But often, we like to look at power in decibels.

play08:09

So let me do that here real quick with the Pow

play08:12

to dB function and then rerun this script.

play08:15

And this is the one-sided power spectrum that I created,

play08:19

and it took several lines of code.

play08:22

But you can type all of this out each time you want

play08:26

to get to the power spectrum.

play08:27

Or you can just get the exact same result

play08:30

with the periodogram function.

play08:32

And there's many different ways to create a periodogram.

play08:35

But here, I'm running it with a rectangular window in FFT,

play08:39

which is the length of the entire signal,

play08:42

and then setting it to return the power spectrum instead

play08:45

of power density.

play08:47

These are the parameters that exactly

play08:49

copy what we just coded above.

play08:51

And you're going to have to take my word for it here,

play08:53

but these two plots are identical.

play08:57

So there we go, right?

play08:58

To get one-sided amplitude, we take 2 times the absolute value

play09:02

of the FFT and divide by N. And to get power,

play09:05

we take 2 times the absolute value of the FFT

play09:07

squared and divide by N squared.

play09:10

That's pretty easy, right?

play09:13

Well, kind of.

play09:14

We have to be really careful here

play09:16

because these results are only true if there are

play09:19

three very important things.

play09:21

One is that we're using a rectangular window and not

play09:24

some other window, like Hamming or Blackman.

play09:27

Two, the time signal is stationary.

play09:30

And three, we're dealing with time signals that

play09:33

produce discrete frequency power spectra and not

play09:37

a continuous spectrum.

play09:39

So let me go through each of these

play09:41

and explain why they're important for these equations

play09:43

to hold.

play09:44

And we're going to start with the rectangular window.

play09:48

When we take the FFT of a time signal,

play09:50

it necessarily must be finite.

play09:53

There is a start time and an end time.

play09:55

And therefore, we're really only looking

play09:57

at a small subset of the total possible infinite signal.

play10:01

And from this subset, we're trying to understand the signal

play10:05

properties.

play10:06

And this subset of data is called a window,

play10:08

since we're only looking at a portion,

play10:10

and the rest is obscured from view.

play10:13

Now, the window could be long, or it could be short.

play10:16

Or we could look at a different part of the signal altogether.

play10:18

But no matter what, we're always just looking at a subset.

play10:23

Now, what I've drawn here is a rectangular window.

play10:26

And this means that each sample in the window is unmodified.

play10:30

That is, we multiply everything inside the window by 1

play10:33

and then 0 for everything outside of the window.

play10:37

And this makes sense, right?

play10:38

I mean, why would you want to change your signal if you're

play10:41

trying to find out the properties of that signal?

play10:44

Well, one reason is for spectral leakage.

play10:46

And one way that spectral leakage occurs

play10:48

is when the period of a time signal frequency

play10:51

is not in integer multiple of the window length.

play10:54

In these cases, cutting a period short

play10:56

like this spreads that signal energy out

play10:58

into neighboring frequency bins, since that summation

play11:01

that we talked about earlier doesn't get

play11:03

fully canceled out by having a complete period.

play11:06

And one way to mitigate this is to just use a longer time

play11:09

series because that leftover period gets

play11:12

averaged across a longer time span.

play11:14

But if that isn't possible, then another way

play11:17

is to just apply a non-rectangular window

play11:19

to your data, something like a hamming window, that

play11:22

attenuates the signal near the edges

play11:24

and reduces the effect of that partial period.

play11:27

Now, this reduces the spectral leakage,

play11:30

but it also comes at a cost of lower resolution.

play11:33

And I'm not going to cover different windows much

play11:35

in this video, I just want you to be aware

play11:38

that you might not always be dealing

play11:39

with a rectangular window.

play11:42

And as you might expect, if you attenuate

play11:44

the signal near the edges, you are, of course,

play11:47

affecting the average amplitude and the average power

play11:50

within that window.

play11:51

Therefore, for the equations that we

play11:53

derived for amplitude and power are only

play11:56

valid for rectangular windows.

play11:58

And there are ways to account for the effects of the window

play12:01

when looking at power, which I'm not

play12:03

going to cover in this video.

play12:05

But if we go back to MATLAB and the periodogram function,

play12:09

we can see that it does handle the effects of the window.

play12:12

Because both hamming and rectangular windows

play12:15

produce the correct power for the 110-hertz frequency

play12:18

that I'm showing here.

play12:22

All right, for the second requirement,

play12:24

the time series must be stationary.

play12:26

And this just means that the signal

play12:28

from a statistical standpoint doesn't change over time.

play12:31

The mean and the variance of the signal

play12:33

are the same regardless of where you look.

play12:36

And here's a way to understand why it's a requirement.

play12:39

Remember back when we were deriving the amplitude,

play12:41

we divided by N because we were looking

play12:44

for an average amplitude?

play12:45

And we had an assumption that the amplitude

play12:48

is relatively constant across the window, right?

play12:50

I mean, take, for example, this signal.

play12:53

It's a single frequency, but the power

play12:56

is changing throughout the window.

play12:58

If we calculate the power for this frequency,

play13:01

it will give us an average across the window.

play13:03

But it won't provide any indication

play13:05

that the power is changing.

play13:07

Now, a worst-case scenario of this

play13:08

is if there is a very short-term, high-powered event

play13:12

that is just averaged across a long window,

play13:15

potentially causing it to be lost in the noise.

play13:20

All right, so we know that we want a rectangular window.

play13:23

And we want the signal within that window to be stationary.

play13:26

Now, for the third requirement, we

play13:28

need the signal to have discrete spectra.

play13:31

And why this is required is really important.

play13:36

To explain why, let's go back over to MATLAB.

play13:39

Here, I have a time signal with two sine waves,

play13:42

one at 100 hertz and one at 110 hertz.

play13:45

And then I'm taking the FFT and then scaling it

play13:48

for the power spectrum.

play13:50

Now, what I'm plotting here is the true power

play13:52

for the two sine waves.

play13:54

And that's the red and yellow stems.

play13:55

And I'm also plotting the power spectrum

play13:57

for the signal, which is the blue curve.

play14:00

And notice how these peaks for the blue curve

play14:02

aren't perfectly sharp, but they're

play14:04

spread out a little bit.

play14:05

And this comes from spectral leakage

play14:07

that occurs because we're using that finite window.

play14:10

But the important thing is that the peak of the power spectrum

play14:14

is at 8.

play14:15

So even with this spread, we're getting an accurate measurement

play14:18

of the power at these frequencies.

play14:21

Now, let me hide the code here so that we

play14:22

can focus on this graph.

play14:24

And watch as I move the frequency of the second sine

play14:27

wave closer to the first.

play14:29

At some point, their spectra start

play14:32

to interfere with each other.

play14:34

And then when they're too close, they merge into a single peak.

play14:38

Now, the value of the y-axis isn't reporting an accurate

play14:42

power at that frequency.

play14:43

In fact, we can't say much of anything

play14:46

about the power of each individual sinusoid.

play14:49

What's being reported is some combination

play14:51

of the two frequencies, that are just too close to each other

play14:54

to separate out.

play14:56

Now, this is just two discrete sine waves.

play14:58

But imagine the case of broadband signals,

play15:01

where the frequency spectrum is continuous.

play15:04

In this plot, I'm showing 50 sinusoids

play15:07

between 100 and 100.5 hertz.

play15:09

And each of them contribute a very small amount of power.

play15:13

But if I zoom out, we can see that the power spectrum

play15:16

for the time signal is much higher because they all

play15:19

contribute a little bit to that total.

play15:22

So hopefully, you can see that this peak doesn't represent

play15:25

a power at a particular frequency,

play15:27

but the power of all of the frequencies

play15:29

that contribute to it.

play15:31

So in some way, it represents power density.

play15:34

This area is much more dense than these areas are,

play15:38

and we can tell that from the peak.

play15:40

And we can normalize this plot by dividing it

play15:43

by some frequency bandwidth, specifically,

play15:45

the equivalent noise bandwidth, which is, in some way,

play15:50

the width of the frequencies that

play15:51

contribute to a particular sample in the power spectrum.

play15:54

And it is a function of the window itself.

play15:58

A finite length window will necessarily

play16:00

blend the power of nearby frequencies

play16:02

together, like we saw.

play16:03

And we can see how this blending occurs

play16:06

by looking at the power spectrum of the window itself.

play16:09

For a rectangular window of length 128 and sampled

play16:13

at 1000 hertz, this is its power spectrum.

play16:16

And I've shifted the negative frequencies

play16:18

to be over on the left, so that we get a better sense of what

play16:20

this curve looks like. l And notice

play16:23

that the window has a maximum power of 1, right at 0 hertz.

play16:27

So the way that we can interpret this

play16:29

is that this window will pass through the power

play16:32

for the frequency that is being sampled unmodified.

play16:35

It's multiplying it by 1.

play16:37

So in this way, we can accurately get the power

play16:40

from a single sine wave.

play16:41

However, along with that value, this window

play16:44

will also add in the power at all of these other delta

play16:47

frequencies attenuated by the amount given by the curve.

play16:51

The longer the window, the steeper

play16:53

the curve, which means that a longer window will have fewer

play16:57

contributions from nearby frequencies

play16:59

than a shorter window does.

play17:02

All right, so each sample in the spectrum

play17:05

is the summation of the attenuated power from all

play17:07

of these nearby frequencies.

play17:08

So we might think that the bandwidth we're interested in

play17:11

is however far out this tail goes,

play17:14

since all of those frequencies are included in some way.

play17:17

But as we can see these, far-away frequencies

play17:20

don't contribute very much.

play17:22

We really only want to consider the frequencies that

play17:24

have the most impact.

play17:26

And the way we find that is to approximate this curve, using

play17:30

a rectangle with height equal to the peak

play17:33

and whose area is equal to the total power.

play17:36

So the area under the blue curve is

play17:39

equal to the area under the red rectangle.

play17:42

And the width of this rectangle is the equivalent noise

play17:45

bandwidth.

play17:46

And under this assumption, we can

play17:49

say that this is the range of frequencies that contribute

play17:52

to each sample in the spectrum.

play17:55

And so to get power spectral density,

play17:58

we divide the power spectrum by the equivalent noise bandwidth.

play18:01

And we know power spectrum.

play18:03

It's the absolute value of the FFT

play18:04

squared divided by N squared.

play18:06

And this is the equation for the equivalent noise bandwidth

play18:10

for an arbitrary window.

play18:11

And I'll leave a link below to a derivation for it.

play18:14

But the way that we read this is that we

play18:16

square each of the terms in the window,

play18:18

and then sum them all up and multiply that by the sample

play18:21

rate, and then divide by the sum of the window

play18:24

terms, which is then squared.

play18:27

And so for a rectangular window, each of the N terms

play18:31

have a value of 1.

play18:32

And so this just becomes fs times N over N squared,

play18:36

or fs divided by N. And now, when we divide the power

play18:41

spectrum by this, the Ns cancel out,

play18:43

and we're left with 1 over fs times N

play18:45

times the absolute value of the FFT squared.

play18:48

And this is the scaling for power spectral density

play18:51

using a rectangular window.

play18:54

And for the last time in this video,

play18:56

let's go back to the MATLAB script and see it in action.

play19:00

And you know what's going on at this point, right?

play19:02

We're just taking the absolute value of the FFT,

play19:04

squaring it, and dividing by fs times N. And voila, the power

play19:09

spectral density.

play19:11

And instead of typing all of this out again,

play19:13

we can use the periodogram function to generate the PSD.

play19:17

And the nice thing about this function

play19:19

is that it's really easy to change the output to power

play19:22

or to change the window and see the results really quickly.

play19:27

Now, if you want to play around with this script a little bit,

play19:30

I've left a link to it below.

play19:32

But I hope that this whole thing has cleared up some confusion

play19:35

about the FFT and power.

play19:36

And the thing to remember is that if your signal is made up

play19:39

of a few dominant sine waves, then

play19:41

you can look at the power spectrum

play19:42

to get the power in those frequencies.

play19:44

However, if there are broadband signals,

play19:47

then it probably makes more sense to look at the PSD

play19:50

instead, since that returns the power per frequency band.

play19:54

And mathematically, you can take the PSD of a single sine wave

play19:58

or the power spectrum of wide band signals,

play20:01

and you're going to get a plot.

play20:02

But the trouble comes when you try to tie those plots back

play20:06

to some physical property in the time domain.

play20:09

Because they just won't make much sense.

play20:11

And this is why you have to know what you're

play20:13

trying to accomplish and what kind of signal

play20:15

you're looking at, in order to choose the correct tool.

play20:19

All right, so that's where I'm going to leave this video.

play20:22

Don't forget to subscribe to this channel

play20:24

so you don't miss any future videos.

play20:26

Also, you can find all of the Tech Talk videos

play20:28

across many different topics nicely organized

play20:30

at mathworks.com.

play20:32

And if you liked this video, then you

play20:34

might be interested to learn about the Fast Fourier

play20:36

Transform in our video on the FFT and the DFT.

play20:40

All right, thanks for watching, and I'll see you next time.

Rate This

5.0 / 5 (0 votes)

Вам нужно краткое изложение на английском?