next up previous contents
Next: Using cross-correlation to line Up: Time domain analysis Previous: Enveloping   Contents

Generating a signal from a frequency vector

Something that arises occasionally is that you have a vector of frequencies f, and you want to generate a frequency modulated signal with that frequency. For example, maybe you have a vector of frequency versus time for a shaft, and you are trying to generate a simulated vibration profile that tracks with speed. Your first temptation is going to be sig=sin(2 * pi * f * t), but that will not work. Try the following quick example in matlab: Fs = 1000; t = 0:(1/Fs):10; freq= 6+(t/5).^2; sig = sin( 2 * pi * freq .* t); figure; plot(t, sig); xlim([9.8 10]). You can easily see that freq(end) is 6+(10/5)^2=10, so you'd expect that the last cycle would have a period of 100ms, but in fact it's more like 55ms, which is much too fast.

Here is why: if we have a continuous function f (t), what we really want to plot is sin($ \theta$(t)). How do we get from f (t) to $ \theta$(t)? The answer is not multiply by t, but integrate with respect to time. In other words $ \theta$(t) = 2$ \pi$$ \int_{{0}}^{{t}}$f ($ \tau$)d$ \tau$. Now, if f (t) = f0, where f0 is a constant, then we have simply $ \theta$(t) = 2$ \pi$$ \int_{{0}}^{{t}}$f0d$ \tau$ = 2$ \pi$f0$ \int_{{0}}^{{t}}$d$ \tau$ = 2$ \pi$f0t. So if our frequency is constant, we can just multiply by t, but if it is non-constant, we have to integrate.

Here's the matlab code you want to use: theta = cumtrapz( t, freq); sig2 = sin( 2 * pi * theta); figure; plot(t, sig2); xlim([9.8 10]). You can see this now gives the expected period for the last cycle.


next up previous contents
Next: Using cross-correlation to line Up: Time domain analysis Previous: Enveloping   Contents " . $row['Name'] . " Posted on " . $row['DateTime']; echo "
"; echo $row['Comment']; echo "

"; } echo "
"; ?> Leave a comment on this page:

Name: (optional)
To prove you are not a robot, what is 2+3?

Creative Commons License
This work by Daniel Kiracofe (daniel dot kiracofe at gmail dot com) is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License./' $I