0:00:00.000,0:00:09.112 Alright. So, one other problem associated[br]with this, which is you might say, 0:00:09.112,0:00:13.526 something like, well, okay, this is all[br]fine and good. In fact, if it's really 0:00:13.526,0:00:18.060 noise, then even if I go to the time[br]domain, I could just take my time domain 0:00:18.060,0:00:23.131 and just kinda like average my time domain[br]and I should get the little bump out that 0:00:23.131,0:00:28.270 I'm expecting in the time domain. Okay. So[br]I'm gonna show you one example where that 0:00:28.270,0:00:33.079 actually does not work. Cuz what happens[br]if it's moving in a time domain? That's 0:00:33.079,0:00:37.172 what we wanna address. Okay? Everybody[br]good with that? Kinda cool? Simple 0:00:37.172,0:00:42.300 filtering, simple making use of the fact[br]that you know something about noise. 0:00:43.300,0:00:53.006 Alright. So, let's do something a little[br]more complicated and let's come back up 0:00:53.006,0:00:58.386 actually to the board real quick here and[br]to motivate it, cuz I, I just you know, 0:00:58.386,0:01:04.227 it's hard to get motivated. That's helping[br]out. Alright. If I could get a [INAUDIBLE] 0:01:04.227,0:01:12.570 Oh, there's my eraser. Alright. So here is[br]the deal. If you really do have this 0:01:12.570,0:01:22.371 airplane flying around up here, it's[br]moving, and in some sense, you kinda go 0:01:22.371,0:01:27.903 like you know, presumably it's moving[br]pretty fast. Okay? So in 30 seconds, this 0:01:27.903,0:01:33.503 thing can go a pretty long ways if you've[br]got a plane going you know, close to Mach 0:01:33.503,0:01:38.023 one or Mach two or Mach three.[br]Okay? Normally, we think of that going 0:01:38.023,0:01:43.150 super fast and you're saying, well, I have[br]a signal now that as I keep taking 0:01:43.150,0:01:48.412 information out of this, the information[br]actually is translating along. Okay? So, 0:01:48.412,0:01:53.607 if you are thinking about saying, well, I[br]could just send a time domain, take the 0:01:53.607,0:01:59.064 signal, and just average it. Well, the[br]signal's here and now it's moving that way 0:01:59.064,0:02:03.243 like my, Mach two.[br]Okay? So you can't just average this out, 0:02:03.243,0:02:09.181 because this will just average out to zero[br]as well. The signal is gone. If you look 0:02:09.181,0:02:17.342 in the time domain, you average a moving[br]signal, it's gone. However, the frequency 0:02:17.342,0:02:23.878 signature doesn't change. So if I bounce[br]stuff off of here, it would still come 0:02:23.878,0:02:29.028 back, as, let's say we're making up, that[br]doesn't change, so my frequency signature 0:02:29.028,0:02:34.460 doesn't change. Now, if you are really[br]clever engineer and you could actually 0:02:34.920,0:02:40.941 find a way to make your plane shift its[br]frequency and start getting frequent, 0:02:40.941,0:02:45.756 signatures, frequency signature all over[br]the place, the filter wouldn't be able to 0:02:45.756,0:02:49.454 pick it up very well. Right? Cuz you'd[br]shift it you know, oh, wait, wait a 0:02:49.454,0:02:53.395 minute, I was, I was filtering over here[br]but now you've moved your you know, if you 0:02:53.395,0:02:57.141 can, if you can do something like that.[br]Okay? Through frequency conversion then 0:02:57.141,0:03:01.374 you could screw up a detector, but what[br]we're gonna do is very simple, which is if 0:03:01.374,0:03:05.753 you do this, no is coming back. This thing[br]is moving and if you try to average in the 0:03:05.753,0:03:09.549 time domain, you get zero. You get nothing[br]out of it. However, you average in the 0:03:09.549,0:03:14.288 frequency domain, you can recover[br]everything. Okay? Again, like your dog 0:03:14.288,0:03:21.582 problem. Nathaniel, how's it going back[br]there? Do you go by Nate? Nathaniel? 0:03:21.582,0:03:27.146 Nathan? Nate, all right. Okay, so there's[br]no confusion, because I go by Nate Dogg, 0:03:27.146,0:03:31.956 cuz it's my rapper name. So as long as you[br]stay away from that one, we're all good. 0:03:31.956,0:03:36.012 Okay. So the dog problem Nate, right, is[br]there's this moving marble in the 0:03:36.012,0:03:40.358 intestine of your dog that you gotta blow[br]up. So you gotta know where it is 0:03:40.358,0:03:44.531 accurately or else it'll blow up other[br]parts of the dog. By the way, it's kind of 0:03:44.879,0:03:49.051 interesting. anybody in biomedical[br]engineer in here? Right. So is there 0:03:49.051,0:03:54.163 somebody in my class that had this, couple[br]years back that they were looking at, like 0:03:54.163,0:03:59.455 trying to you know, shoot kidney stones.[br]And, I was amazed when they're talking on 0:03:59.455,0:04:04.262 the side in a thesis, how many times they[br]miss? Like, they shoot these big things to 0:04:04.262,0:04:08.717 crush the kidney stone, but you know,[br]people move, fluid stuff moves, and then 0:04:08.717,0:04:13.706 it just misses. Well, that does damage to[br]other parts of your body. Anyway, just 0:04:13.706,0:04:19.197 want to let you know that. So sit really[br]still if you gotta get a shoot kidney 0:04:19.197,0:04:24.218 stone shot. Okay? And so that's what[br]you're doing with your dog. The particle 0:04:24.218,0:04:29.441 itself is moving and the signature is[br]constant in frequency. So you gotta have 0:04:29.441,0:04:34.317 to figure out where that frequency sits[br]and go after that. Okay? Alright. So 0:04:34.317,0:04:38.684 that's also here, it's moving, that's[br]okay. If this is moving super fast, all 0:04:38.684,0:04:43.230 you got to key on is the frequency[br]signature because that plane can't shift 0:04:43.230,0:04:47.918 the, can't shift the frequency that you're[br]sending out. Yeah. Would effects due to 0:04:47.918,0:04:52.052 the Doppler Effect ever be important in a[br]problem like this or? Yeah, in fact you 0:04:52.052,0:04:56.291 know, what I'm talking about is such basic[br]radar stuff, right? But, actually, you can 0:04:56.291,0:05:00.372 do all kinds of data processing making use[br]of that. Yeah, in fact, you would, you 0:05:00.372,0:05:04.506 would definitely make use of that. That[br]would give you sort of, for instance, how 0:05:04.506,0:05:08.431 fast is that thing moving, much more[br]accurately and quickly. It's giving you 0:05:08.431,0:05:14.828 some kind of information. Okay. So let's,[br]let's program up, then a signal and I'll 0:05:14.828,0:05:20.785 show you sort of what it might look like[br]in time and frequency before you 0:05:21.429,0:05:30.101 pre-process. And, you get to learn a[br]little bit of fancy MATLAB. Okay. So, 0:05:29.810,0:05:37.579 let's come back to here and what I wanna[br]do is, I wanna plot a signal that's moving 0:05:37.579,0:05:45.056 in time and then I wanna plot what its[br]frequency spectrum looks like as well. 0:05:45.056,0:05:52.835 Okay. So let's come back up to here and[br]I'm gonna kill it from there. Okay. So we 0:05:52.835,0:05:59.209 still have all our stuff here. We have our[br]k, our t, and now what I'm gonna do in 0:05:59.209,0:06:06.118 fact, I think I made this a little bit[br]bigger. I'm gonna do this to be 60. So, 0:06:06.118,0:06:14.802 here's what I'm gonna do. I'm gonna define[br]a thing called slice. It's a vector, goes 0:06:14.802,0:06:20.334 from zero, steps from 0.5 to ten. This is[br]gonna be like my time slices times zero, I 0:06:20.334,0:06:26.229 take a reading. A time and a half, I take[br]a reading. could be so for instance that I 0:06:26.229,0:06:31.340 take or, or half a minute, I take a[br]reading. Whatever this happens to be in 0:06:31.340,0:06:36.881 units and I just keep taking readings, at[br]every 0.5 all the way to ten. So I have a 0:06:36.881,0:06:41.876 total of 21 readings I'm gonna take the[br]data, 'kay, which isn't a whole lot, but 0:06:41.876,0:06:47.349 fine just for example. And what I wanna do[br]is define some new variables, call them T 0:06:47.349,0:06:54.493 and S, which is gonna be what's called a[br]meshgrid(t,slice). 0:06:54.497,0:06:59.965 Yes? You have already, already defined[br]capital C on line three. Is that gonna 0:06:59.965,0:07:04.149 conflict it all with. Oh, I just overwrote[br]it. That's okay. Yeah, but. Tha t's okay. 0:07:04.149,0:07:09.609 Yeah, I mean, if I wanted to use this[br]again at some point, this is the kind of 0:07:10.034,0:07:15.423 programming mistake that's so rookie, I[br]would never make it. I just did it in 0:07:15.423,0:07:21.375 class to show you what kind of mistakes[br]you can make. Yeah, rookie move. We'll 0:07:21.375,0:07:29.513 stay with it though, just to show that no[br]matter how far in life you go. you know, I 0:07:29.513,0:07:35.069 have a couple of mantras about teaching[br]and you've heard them I think, in my class 0:07:35.069,0:07:39.377 before it knows, there's two things you[br]never do, ever. I mean this is the best 0:07:39.377,0:07:44.309 advice I have to give ever in my whole[br]life. first you don't do, you don't spell 0:07:44.309,0:07:48.617 in public and you don't do algebra in[br]public, cuz you will eventually do 0:07:48.617,0:07:52.869 something so stupid, like wow, like I[br]can't spell dog or can't add two to ten to 0:07:52.869,0:07:57.461 get cuz you're up there you know, and[br]you're nervous and everybody sees it, so 0:07:57.461,0:08:01.940 just don't do if you don't have to. I[br]would love to say don't program in public. 0:08:03.500,0:08:09.810 But unfortunately for this class, I cannot[br]get around that one. Alright. So there you 0:08:09.810,0:08:16.273 go. now what does the meshgrid do by the[br]way? What I'm thinking about right now, is 0:08:16.273,0:08:23.945 I'm taking time slices of data, so what t[br]is, right? Little t, here. T is, goes from 0:08:23.945,0:08:32.606 you know, -30 to 30 and I have a signal on[br]that. So, I have this domain where, okay, 0:08:32.606,0:08:37.780 so I have, for every, every little burst[br]of time, I take examples of length 60. 0:08:38.040,0:08:43.189 Okay? And I divide that 60 by 512, and[br]then, 0.5 units later is a different 0:08:43.189,0:08:50.884 units. I take another sample, another[br]measurement, again, with 512 points in it 0:08:50.884,0:08:56.260 and another in 512 points. Okay? So I'm[br]gonna collect this and what meshgrid does, 0:08:56.260,0:09:01.360 it gives us a sense of direction. It makes[br]a two-dimensional grid where in 0:09:01.636,0:09:06.667 one-dimension, it's time, in the other[br]dimension, it's this slice variable. Okay? 0:09:06.667,0:09:11.698 So t and slice now become capital T and[br]capital S, which are now matrices 0:09:11.698,0:09:17.212 conveying information about you know, ones[br]in one direction. One is in an orthogonal 0:09:17.212,0:09:24.624 direction to it. Okay? I wanna use those[br]to define our signal and we also need this 0:09:24.624,0:09:35.382 in the frequency domain, K, S. We're gonna[br]do the same thing here with the frequency 0:09:35.382,0:09:39.274 components .[br]In one direction, it's the wave numbers, 0:09:39.274,0:09:43.924 but then, it's wave number per sample in,[br]in the other direction, it's number 0:09:43.924,0:09:49.361 samples. Okay? Now, let's define a[br]function. Here it is, u=sech Now, I use 0:09:49.361,0:09:56.979 these variables cuz now they know about[br]their direction and I'll just show you 0:09:56.979,0:10:04.297 what I've got here, and so you can, it's a[br]simple function. I'm gonna, I'm gonna 0:10:04.297,0:10:09.086 leave this zero for right now. I'm gonna[br]tell you why in a moment cuz I wanna shift 0:10:09.086,0:10:13.425 the center frequency around. This is a[br]center frequency. If I leave it at zero, 0:10:13.425,0:10:18.158 it means that in the frequency domain I'm[br]centered at k equals zero, but we can make 0:10:18.158,0:10:22.271 this anything we want. I can make it[br]centered at k equals whatever else. I 0:10:22.271,0:10:26.722 want, in fact, in your dog problem, I'm[br]telling you right now if you put a filter 0:10:26.722,0:10:32.035 around k equals zero, your dog will die.[br]Tim, don't let your dog die. Okay. 0:10:32.035,0:10:37.287 Alright? So, alright, so don't put a[br]filter near zero, cuz it won't save 0:10:37.287,0:10:42.996 anybody. Alright. So that's gonna be my[br]function and so what I'm gonna do is 0:10:42.996,0:10:50.189 subplot this. I'm gonna say, okay, I'm[br]gonna use what's called the waterfall 0:10:50.189,0:10:59.509 command. And I like waterfall, because[br]it's a black and white picture, and it's 0:10:59.509,0:11:04.455 nicer to plot in color, however, I want to[br]set a view angle on it. The problem with 0:11:04.455,0:11:09.140 plotting in color is if you go to a[br]journal, it costs you a lot of money. 0:11:09.420,0:11:16.942 Okay. So there is like my plane moving[br]around, whatever you want to call it. This 0:11:16.942,0:11:21.536 thing is moving in time, right? So I have[br]this signal that's moving around and I 0:11:21.536,0:11:25.892 made a very simple movement. I made it[br]move like a sign wave in the slice 0:11:25.892,0:11:30.644 direction. So, it's just doing this. Okay?[br]All right. Now if I add noise to this and 0:11:30.644,0:11:37.385 I. No it's time domain, here. We're going[br]to look at the frequency in a moment. So, 0:11:37.385,0:11:42.870 if I add noise to this you know, we could[br]bury this whole thing, we could hide it. 0:11:42.870,0:11:47.876 And he said, well, yeah but I could just[br]average it to zero. If you average that, 0:11:47.876,0:11:52.675 this stuff all gets washed out. You get no[br]signal out. You have to do it in a 0:11:52.675,0:11:58.023 frequency domain. Okay? Alright. So, let's[br]take a look at the frequency domain of 0:11:58.023,0:12:03.440 this thing. So I have the signal moving[br]around in time, but if I just take this 0:12:03.783,0:12:08.788 Fourier transform then I can plot this[br]thing there. So, okay, so let's go ahead 0:12:08.788,0:12:24.340 over here. That's the first plot, and, so[br]I gotta do is that gonna go through this 0:12:24.340,0:12:29.633 and one slice at a time for every slice[br]take Fourier transform. Okay? So I say, 0:12:29.633,0:12:36.860 okay, fine. So what I'll do is I'll go[br]over here and I'm gonna say I will go grab 0:12:36.860,0:12:48.146 the first, first, let's say row of this u.[br]I'm going to ftt it. I just Fourier 0:12:48.146,0:12:55.406 transformed that first row and what I'm[br]going to do with this Fourier transform is 0:12:55.406,0:13:03.808 I'm going to plot it. So let's call this[br]UT j, okay? And, once I go through all of 0:13:03.808,0:13:12.110 this. Oh, come on. And actually, I don't[br]care about fft j or I, what I want to do 0:13:12.110,0:13:17.272 is maybe plot also, if fftshift it right[br]now. Okay? Cuz I just want to plot what 0:13:17.272,0:13:24.936 this looks like. There is my thing there.[br]And, might as well take the absolute value 0:13:24.936,0:13:33.536 while we're at it, for a moment, we're[br]gonna just this thing, absolute value. So 0:13:33.536,0:13:37.869 what I did here is I went to each row,[br]Fourier transformed it, then I have to 0:13:37.869,0:13:41.939 fft(shift) it with, with the absolute[br]value. And then what we can do is say, 0:13:41.939,0:13:52.091 okay, how about we look in subplot(2) and[br]I'm gonna do the waterfall again. But now, 0:13:52.091,0:14:04.380 I need the fftshift. Actually, did I do[br]this yeah, of, of K versus S versus UT. 0:14:05.100,0:14:14.198 Okay? So that's gonna be this Fourier[br]Transform. Oh, I should set the same view 0:14:14.198,0:14:30.817 angle, by the way. Sorry. Okay. So here's,[br]here is, here is perfect signal, which 0:14:30.817,0:14:36.684 doesn't exist in reality, right? Which is[br]I have this thing moving around and it's 0:14:36.684,0:14:45.524 moving in time. Tell me what it's doing in[br]frequency domain. Nothing. Awesome, right? 0:14:45.524,0:14:49.559 Because it's very important you know[br]what's happening in time and the whole 0:14:49.559,0:14:53.650 section at the beginning is kind of[br]understanding this idea between time 0:14:53.650,0:14:57.965 frequency dynamics. The time domain can be[br]doing all kinds of stuff, only that 0:14:57.965,0:15:02.392 frequency fixed. Okay? Remember, when we[br]do the noise reduction, your key thing is 0:15:02.392,0:15:07.043 to say, well, if I, if this thing is fixed[br]in frequency, all I got to do is build a 0:15:07.043,0:15:11.437 little filter out there in freque ncy,[br]capture that out. Okay? Cuz this thing is 0:15:11.437,0:15:16.225 not moving around. So I can be moving all[br]over the place, flying around my jet, 0:15:16.225,0:15:21.137 you're still giving off a fixed frequency[br]and this is what you'd lock in on, if 0:15:21.137,0:15:22.879 you're gonna do a detection.