Return to Video

W01_L03_P03 - Moving signals and averaging in frequency

  • 0:00 - 0:09
    Alright. So, one other problem associated
    with this, which is you might say,
  • 0:09 - 0:14
    something like, well, okay, this is all
    fine and good. In fact, if it's really
  • 0:14 - 0:18
    noise, then even if I go to the time
    domain, I could just take my time domain
  • 0:18 - 0:23
    and just kinda like average my time domain
    and I should get the little bump out that
  • 0:23 - 0:28
    I'm expecting in the time domain. Okay. So
    I'm gonna show you one example where that
  • 0:28 - 0:33
    actually does not work. Cuz what happens
    if it's moving in a time domain? That's
  • 0:33 - 0:37
    what we wanna address. Okay? Everybody
    good with that? Kinda cool? Simple
  • 0:37 - 0:42
    filtering, simple making use of the fact
    that you know something about noise.
  • 0:43 - 0:53
    Alright. So, let's do something a little
    more complicated and let's come back up
  • 0:53 - 0:58
    actually to the board real quick here and
    to motivate it, cuz I, I just you know,
  • 0:58 - 1:04
    it's hard to get motivated. That's helping
    out. Alright. If I could get a [INAUDIBLE]
  • 1:04 - 1:13
    Oh, there's my eraser. Alright. So here is
    the deal. If you really do have this
  • 1:13 - 1:22
    airplane flying around up here, it's
    moving, and in some sense, you kinda go
  • 1:22 - 1:28
    like you know, presumably it's moving
    pretty fast. Okay? So in 30 seconds, this
  • 1:28 - 1:34
    thing can go a pretty long ways if you've
    got a plane going you know, close to Mach
  • 1:34 - 1:38
    one or Mach two or Mach three.
    Okay? Normally, we think of that going
  • 1:38 - 1:43
    super fast and you're saying, well, I have
    a signal now that as I keep taking
  • 1:43 - 1:48
    information out of this, the information
    actually is translating along. Okay? So,
  • 1:48 - 1:54
    if you are thinking about saying, well, I
    could just send a time domain, take the
  • 1:54 - 1:59
    signal, and just average it. Well, the
    signal's here and now it's moving that way
  • 1:59 - 2:03
    like my, Mach two.
    Okay? So you can't just average this out,
  • 2:03 - 2:09
    because this will just average out to zero
    as well. The signal is gone. If you look
  • 2:09 - 2:17
    in the time domain, you average a moving
    signal, it's gone. However, the frequency
  • 2:17 - 2:24
    signature doesn't change. So if I bounce
    stuff off of here, it would still come
  • 2:24 - 2:29
    back, as, let's say we're making up, that
    doesn't change, so my frequency signature
  • 2:29 - 2:34
    doesn't change. Now, if you are really
    clever engineer and you could actually
  • 2:35 - 2:41
    find a way to make your plane shift its
    frequency and start getting frequent,
  • 2:41 - 2:46
    signatures, frequency signature all over
    the place, the filter wouldn't be able to
  • 2:46 - 2:49
    pick it up very well. Right? Cuz you'd
    shift it you know, oh, wait, wait a
  • 2:49 - 2:53
    minute, I was, I was filtering over here
    but now you've moved your you know, if you
  • 2:53 - 2:57
    can, if you can do something like that.
    Okay? Through frequency conversion then
  • 2:57 - 3:01
    you could screw up a detector, but what
    we're gonna do is very simple, which is if
  • 3:01 - 3:06
    you do this, no is coming back. This thing
    is moving and if you try to average in the
  • 3:06 - 3:10
    time domain, you get zero. You get nothing
    out of it. However, you average in the
  • 3:10 - 3:14
    frequency domain, you can recover
    everything. Okay? Again, like your dog
  • 3:14 - 3:22
    problem. Nathaniel, how's it going back
    there? Do you go by Nate? Nathaniel?
  • 3:22 - 3:27
    Nathan? Nate, all right. Okay, so there's
    no confusion, because I go by Nate Dogg,
  • 3:27 - 3:32
    cuz it's my rapper name. So as long as you
    stay away from that one, we're all good.
  • 3:32 - 3:36
    Okay. So the dog problem Nate, right, is
    there's this moving marble in the
  • 3:36 - 3:40
    intestine of your dog that you gotta blow
    up. So you gotta know where it is
  • 3:40 - 3:45
    accurately or else it'll blow up other
    parts of the dog. By the way, it's kind of
  • 3:45 - 3:49
    interesting. anybody in biomedical
    engineer in here? Right. So is there
  • 3:49 - 3:54
    somebody in my class that had this, couple
    years back that they were looking at, like
  • 3:54 - 3:59
    trying to you know, shoot kidney stones.
    And, I was amazed when they're talking on
  • 3:59 - 4:04
    the side in a thesis, how many times they
    miss? Like, they shoot these big things to
  • 4:04 - 4:09
    crush the kidney stone, but you know,
    people move, fluid stuff moves, and then
  • 4:09 - 4:14
    it just misses. Well, that does damage to
    other parts of your body. Anyway, just
  • 4:14 - 4:19
    want to let you know that. So sit really
    still if you gotta get a shoot kidney
  • 4:19 - 4:24
    stone shot. Okay? And so that's what
    you're doing with your dog. The particle
  • 4:24 - 4:29
    itself is moving and the signature is
    constant in frequency. So you gotta have
  • 4:29 - 4:34
    to figure out where that frequency sits
    and go after that. Okay? Alright. So
  • 4:34 - 4:39
    that's also here, it's moving, that's
    okay. If this is moving super fast, all
  • 4:39 - 4:43
    you got to key on is the frequency
    signature because that plane can't shift
  • 4:43 - 4:48
    the, can't shift the frequency that you're
    sending out. Yeah. Would effects due to
  • 4:48 - 4:52
    the Doppler Effect ever be important in a
    problem like this or? Yeah, in fact you
  • 4:52 - 4:56
    know, what I'm talking about is such basic
    radar stuff, right? But, actually, you can
  • 4:56 - 5:00
    do all kinds of data processing making use
    of that. Yeah, in fact, you would, you
  • 5:00 - 5:05
    would definitely make use of that. That
    would give you sort of, for instance, how
  • 5:05 - 5:08
    fast is that thing moving, much more
    accurately and quickly. It's giving you
  • 5:08 - 5:15
    some kind of information. Okay. So let's,
    let's program up, then a signal and I'll
  • 5:15 - 5:21
    show you sort of what it might look like
    in time and frequency before you
  • 5:21 - 5:30
    pre-process. And, you get to learn a
    little bit of fancy MATLAB. Okay. So,
  • 5:30 - 5:38
    let's come back to here and what I wanna
    do is, I wanna plot a signal that's moving
  • 5:38 - 5:45
    in time and then I wanna plot what its
    frequency spectrum looks like as well.
  • 5:45 - 5:53
    Okay. So let's come back up to here and
    I'm gonna kill it from there. Okay. So we
  • 5:53 - 5:59
    still have all our stuff here. We have our
    k, our t, and now what I'm gonna do in
  • 5:59 - 6:06
    fact, I think I made this a little bit
    bigger. I'm gonna do this to be 60. So,
  • 6:06 - 6:15
    here's what I'm gonna do. I'm gonna define
    a thing called slice. It's a vector, goes
  • 6:15 - 6:20
    from zero, steps from 0.5 to ten. This is
    gonna be like my time slices times zero, I
  • 6:20 - 6:26
    take a reading. A time and a half, I take
    a reading. could be so for instance that I
  • 6:26 - 6:31
    take or, or half a minute, I take a
    reading. Whatever this happens to be in
  • 6:31 - 6:37
    units and I just keep taking readings, at
    every 0.5 all the way to ten. So I have a
  • 6:37 - 6:42
    total of 21 readings I'm gonna take the
    data, 'kay, which isn't a whole lot, but
  • 6:42 - 6:47
    fine just for example. And what I wanna do
    is define some new variables, call them T
  • 6:47 - 6:54
    and S, which is gonna be what's called a
    meshgrid(t,slice).
  • 6:54 - 7:00
    Yes? You have already, already defined
    capital C on line three. Is that gonna
  • 7:00 - 7:04
    conflict it all with. Oh, I just overwrote
    it. That's okay. Yeah, but. Tha t's okay.
  • 7:04 - 7:10
    Yeah, I mean, if I wanted to use this
    again at some point, this is the kind of
  • 7:10 - 7:15
    programming mistake that's so rookie, I
    would never make it. I just did it in
  • 7:15 - 7:21
    class to show you what kind of mistakes
    you can make. Yeah, rookie move. We'll
  • 7:21 - 7:30
    stay with it though, just to show that no
    matter how far in life you go. you know, I
  • 7:30 - 7:35
    have a couple of mantras about teaching
    and you've heard them I think, in my class
  • 7:35 - 7:39
    before it knows, there's two things you
    never do, ever. I mean this is the best
  • 7:39 - 7:44
    advice I have to give ever in my whole
    life. first you don't do, you don't spell
  • 7:44 - 7:49
    in public and you don't do algebra in
    public, cuz you will eventually do
  • 7:49 - 7:53
    something so stupid, like wow, like I
    can't spell dog or can't add two to ten to
  • 7:53 - 7:57
    get cuz you're up there you know, and
    you're nervous and everybody sees it, so
  • 7:57 - 8:02
    just don't do if you don't have to. I
    would love to say don't program in public.
  • 8:04 - 8:10
    But unfortunately for this class, I cannot
    get around that one. Alright. So there you
  • 8:10 - 8:16
    go. now what does the meshgrid do by the
    way? What I'm thinking about right now, is
  • 8:16 - 8:24
    I'm taking time slices of data, so what t
    is, right? Little t, here. T is, goes from
  • 8:24 - 8:33
    you know, -30 to 30 and I have a signal on
    that. So, I have this domain where, okay,
  • 8:33 - 8:38
    so I have, for every, every little burst
    of time, I take examples of length 60.
  • 8:38 - 8:43
    Okay? And I divide that 60 by 512, and
    then, 0.5 units later is a different
  • 8:43 - 8:51
    units. I take another sample, another
    measurement, again, with 512 points in it
  • 8:51 - 8:56
    and another in 512 points. Okay? So I'm
    gonna collect this and what meshgrid does,
  • 8:56 - 9:01
    it gives us a sense of direction. It makes
    a two-dimensional grid where in
  • 9:02 - 9:07
    one-dimension, it's time, in the other
    dimension, it's this slice variable. Okay?
  • 9:07 - 9:12
    So t and slice now become capital T and
    capital S, which are now matrices
  • 9:12 - 9:17
    conveying information about you know, ones
    in one direction. One is in an orthogonal
  • 9:17 - 9:25
    direction to it. Okay? I wanna use those
    to define our signal and we also need this
  • 9:25 - 9:35
    in the frequency domain, K, S. We're gonna
    do the same thing here with the frequency
  • 9:35 - 9:39
    components .
    In one direction, it's the wave numbers,
  • 9:39 - 9:44
    but then, it's wave number per sample in,
    in the other direction, it's number
  • 9:44 - 9:49
    samples. Okay? Now, let's define a
    function. Here it is, u=sech Now, I use
  • 9:49 - 9:57
    these variables cuz now they know about
    their direction and I'll just show you
  • 9:57 - 10:04
    what I've got here, and so you can, it's a
    simple function. I'm gonna, I'm gonna
  • 10:04 - 10:09
    leave this zero for right now. I'm gonna
    tell you why in a moment cuz I wanna shift
  • 10:09 - 10:13
    the center frequency around. This is a
    center frequency. If I leave it at zero,
  • 10:13 - 10:18
    it means that in the frequency domain I'm
    centered at k equals zero, but we can make
  • 10:18 - 10:22
    this anything we want. I can make it
    centered at k equals whatever else. I
  • 10:22 - 10:27
    want, in fact, in your dog problem, I'm
    telling you right now if you put a filter
  • 10:27 - 10:32
    around k equals zero, your dog will die.
    Tim, don't let your dog die. Okay.
  • 10:32 - 10:37
    Alright? So, alright, so don't put a
    filter near zero, cuz it won't save
  • 10:37 - 10:43
    anybody. Alright. So that's gonna be my
    function and so what I'm gonna do is
  • 10:43 - 10:50
    subplot this. I'm gonna say, okay, I'm
    gonna use what's called the waterfall
  • 10:50 - 11:00
    command. And I like waterfall, because
    it's a black and white picture, and it's
  • 11:00 - 11:04
    nicer to plot in color, however, I want to
    set a view angle on it. The problem with
  • 11:04 - 11:09
    plotting in color is if you go to a
    journal, it costs you a lot of money.
  • 11:09 - 11:17
    Okay. So there is like my plane moving
    around, whatever you want to call it. This
  • 11:17 - 11:22
    thing is moving in time, right? So I have
    this signal that's moving around and I
  • 11:22 - 11:26
    made a very simple movement. I made it
    move like a sign wave in the slice
  • 11:26 - 11:31
    direction. So, it's just doing this. Okay?
    All right. Now if I add noise to this and
  • 11:31 - 11:37
    I. No it's time domain, here. We're going
    to look at the frequency in a moment. So,
  • 11:37 - 11:43
    if I add noise to this you know, we could
    bury this whole thing, we could hide it.
  • 11:43 - 11:48
    And he said, well, yeah but I could just
    average it to zero. If you average that,
  • 11:48 - 11:53
    this stuff all gets washed out. You get no
    signal out. You have to do it in a
  • 11:53 - 11:58
    frequency domain. Okay? Alright. So, let's
    take a look at the frequency domain of
  • 11:58 - 12:03
    this thing. So I have the signal moving
    around in time, but if I just take this
  • 12:04 - 12:09
    Fourier transform then I can plot this
    thing there. So, okay, so let's go ahead
  • 12:09 - 12:24
    over here. That's the first plot, and, so
    I gotta do is that gonna go through this
  • 12:24 - 12:30
    and one slice at a time for every slice
    take Fourier transform. Okay? So I say,
  • 12:30 - 12:37
    okay, fine. So what I'll do is I'll go
    over here and I'm gonna say I will go grab
  • 12:37 - 12:48
    the first, first, let's say row of this u.
    I'm going to ftt it. I just Fourier
  • 12:48 - 12:55
    transformed that first row and what I'm
    going to do with this Fourier transform is
  • 12:55 - 13:04
    I'm going to plot it. So let's call this
    UT j, okay? And, once I go through all of
  • 13:04 - 13:12
    this. Oh, come on. And actually, I don't
    care about fft j or I, what I want to do
  • 13:12 - 13:17
    is maybe plot also, if fftshift it right
    now. Okay? Cuz I just want to plot what
  • 13:17 - 13:25
    this looks like. There is my thing there.
    And, might as well take the absolute value
  • 13:25 - 13:34
    while we're at it, for a moment, we're
    gonna just this thing, absolute value. So
  • 13:34 - 13:38
    what I did here is I went to each row,
    Fourier transformed it, then I have to
  • 13:38 - 13:42
    fft(shift) it with, with the absolute
    value. And then what we can do is say,
  • 13:42 - 13:52
    okay, how about we look in subplot(2) and
    I'm gonna do the waterfall again. But now,
  • 13:52 - 14:04
    I need the fftshift. Actually, did I do
    this yeah, of, of K versus S versus UT.
  • 14:05 - 14:14
    Okay? So that's gonna be this Fourier
    Transform. Oh, I should set the same view
  • 14:14 - 14:31
    angle, by the way. Sorry. Okay. So here's,
    here is, here is perfect signal, which
  • 14:31 - 14:37
    doesn't exist in reality, right? Which is
    I have this thing moving around and it's
  • 14:37 - 14:46
    moving in time. Tell me what it's doing in
    frequency domain. Nothing. Awesome, right?
  • 14:46 - 14:50
    Because it's very important you know
    what's happening in time and the whole
  • 14:50 - 14:54
    section at the beginning is kind of
    understanding this idea between time
  • 14:54 - 14:58
    frequency dynamics. The time domain can be
    doing all kinds of stuff, only that
  • 14:58 - 15:02
    frequency fixed. Okay? Remember, when we
    do the noise reduction, your key thing is
  • 15:02 - 15:07
    to say, well, if I, if this thing is fixed
    in frequency, all I got to do is build a
  • 15:07 - 15:11
    little filter out there in freque ncy,
    capture that out. Okay? Cuz this thing is
  • 15:11 - 15:16
    not moving around. So I can be moving all
    over the place, flying around my jet,
  • 15:16 - 15:21
    you're still giving off a fixed frequency
    and this is what you'd lock in on, if
  • 15:21 - 15:23
    you're gonna do a detection.
Title:
W01_L03_P03 - Moving signals and averaging in frequency

English subtitles

Revisions