<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697</link>
    <title>MATLAB Central Newsreader - Filtering signal with rapid changes with FFT</title>
    <description>Feed for thread: Filtering signal with rapid changes with FFT</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Tue, 04 Aug 2009 07:11:01 -0400</pubDate>
      <title>Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670455</link>
      <author>juho salminen</author>
      <description>Hi guys,&lt;br&gt;
&lt;br&gt;
I'm newbie with signal processing who is trying to implement fft to signal filtering. My problem is following: &lt;br&gt;
My signal is sinusoidial Wave with noise added in it. Wave is decreasing as time passes by.&lt;br&gt;
&lt;br&gt;
My current filtering technique is following: I make FFT of signal, take highest peak from FFT, and cut every sample in frequency domain into 0 except highest peak. &lt;br&gt;
Then I just make ifft of signal. &lt;br&gt;
&lt;br&gt;
This technique suits well for stationary sine wave, but when sine's amplitude changes rapidly with time, it seems that when signal is reversed back to time domain, some distortion to amplitudes of reversed signal is introduced. In my application, I need to get amplitudes of signals very accurately!&lt;br&gt;
&lt;br&gt;
Basicly, what I'm trying is to make filter, which would not make any phase delay for signal, and would fit for signals with different frequencies...&lt;br&gt;
&lt;br&gt;
Is there any other ways to do this kind of filter? &lt;br&gt;
&lt;br&gt;
Could you guys also make some example code also? My signal processing knowledge is basicly 0&lt;br&gt;
&lt;br&gt;
Thanks,&lt;br&gt;
&lt;br&gt;
-Juho&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;</description>
    </item>
    <item>
      <pubDate>Tue, 04 Aug 2009 07:55:19 -0400</pubDate>
      <title>Re: Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670463</link>
      <author>Lorenzo Guerrasio</author>
      <description>&quot;juho salminen&quot; &amp;lt;jssalmi3@cc.hut.fi&amp;gt; wrote in message &amp;lt;h58mu4$2o2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm newbie with signal processing who is trying to implement fft to signal filtering. My problem is following: &lt;br&gt;
&amp;gt; My signal is sinusoidial Wave with noise added in it. Wave is decreasing as time passes by.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My current filtering technique is following: I make FFT of signal, take highest peak from FFT, and cut every sample in frequency domain into 0 except highest peak. &lt;br&gt;
&amp;gt; Then I just make ifft of signal. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This technique suits well for stationary sine wave, but when sine's amplitude changes rapidly with time, it seems that when signal is reversed back to time domain, some distortion to amplitudes of reversed signal is introduced. In my application, I need to get amplitudes of signals very accurately!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Basicly, what I'm trying is to make filter, which would not make any phase delay for signal, and would fit for signals with different frequencies...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there any other ways to do this kind of filter? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Could you guys also make some example code also? My signal processing knowledge is basicly 0&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -Juho&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  &lt;br&gt;
&lt;br&gt;
When you multiply (take away) in frequency, you are convolving in time --&amp;gt;high risk of distortion. What you can do is to use FFT to find the peak of the noise and then apply a notch filter. &lt;br&gt;
However, everything depends on the noise features.&lt;br&gt;
&lt;br&gt;
Regarding fase distortion, you could use filtfilt</description>
    </item>
    <item>
      <pubDate>Tue, 04 Aug 2009 09:26:01 -0400</pubDate>
      <title>Re: Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670480</link>
      <author>juho salminen</author>
      <description>&lt;br&gt;
&quot;Lorenzo Guerrasio&quot; &amp;lt;lorenzo.guerrasio@email.it&amp;gt; wrote in message &amp;lt;h58ph7$ivr$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;juho salminen&quot; &amp;lt;jssalmi3@cc.hut.fi&amp;gt; wrote in message &amp;lt;h58mu4$2o2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I'm newbie with signal processing who is trying to implement fft to signal filtering. My problem is following: &lt;br&gt;
&amp;gt; &amp;gt; My signal is sinusoidial Wave with noise added in it. Wave is decreasing as time passes by.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; My current filtering technique is following: I make FFT of signal, take highest peak from FFT, and cut every sample in frequency domain into 0 except highest peak. &lt;br&gt;
&amp;gt; &amp;gt; Then I just make ifft of signal. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; This technique suits well for stationary sine wave, but when sine's amplitude changes rapidly with time, it seems that when signal is reversed back to time domain, some distortion to amplitudes of reversed signal is introduced. In my application, I need to get amplitudes of signals very accurately!&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Basicly, what I'm trying is to make filter, which would not make any phase delay for signal, and would fit for signals with different frequencies...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Is there any other ways to do this kind of filter? &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Could you guys also make some example code also? My signal processing knowledge is basicly 0&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; -Juho&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt;  &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; When you multiply (take away) in frequency, you are convolving in time --&amp;gt;high risk of distortion. What you can do is to use FFT to find the peak of the noise and then apply a notch filter. &lt;br&gt;
&amp;gt; However, everything depends on the noise features.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Regarding fase distortion, you could use filtfilt&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&quot;What you can do is to use FFT to find the peak of the noise and then apply a notch filter&quot;&lt;br&gt;
&lt;br&gt;
Why a notch filter? Isn't it the same than basicly remove all the noise samples away? Now I'm saving just one peak in frequency domain, I delete everything else. &quot;Peak of the noise&quot; is in this case everything but that peak&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
My noise is normally distributed (randn-function)&lt;br&gt;
&lt;br&gt;
Can you give me an example signal and example of how to use filtfilt-function with this kind of signal so, that there is no amplitude of phase distortion?&lt;br&gt;
&lt;br&gt;
Thanks for all the effort!&lt;br&gt;
&lt;br&gt;
-Juho</description>
    </item>
    <item>
      <pubDate>Tue, 04 Aug 2009 09:45:03 -0400</pubDate>
      <title>Re: Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670483</link>
      <author>Dave Robinson</author>
      <description>&quot;juho salminen&quot; &amp;lt;jssalmi3@cc.hut.fi&amp;gt; wrote in message &amp;lt;h58mu4$2o2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; I'm newbie with signal processing who is trying to implement fft to signal filtering. My problem is following: &lt;br&gt;
&amp;gt; My signal is sinusoidial Wave with noise added in it. Wave is decreasing as time passes by.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My current filtering technique is following: I make FFT of signal, take highest peak from FFT, and cut every sample in frequency domain into 0 except highest peak. &lt;br&gt;
&amp;gt; Then I just make ifft of signal. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; This technique suits well for stationary sine wave, but when sine's amplitude changes rapidly with time, it seems that when signal is reversed back to time domain, some distortion to amplitudes of reversed signal is introduced. In my application, I need to get amplitudes of signals very accurately!&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Basicly, what I'm trying is to make filter, which would not make any phase delay for signal, and would fit for signals with different frequencies...&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Is there any other ways to do this kind of filter? &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Could you guys also make some example code also? My signal processing knowledge is basicly 0&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Thanks,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; -Juho&lt;br&gt;
&lt;br&gt;
Your basic problem appears to be that the moment you apply amplitude modulation, your signal ceases to be a pure sine wave. &lt;br&gt;
&lt;br&gt;
You are in effect taking your time domain sine wave and multiplying by your amplitude modification distribution. In the frequency domain this is equivelent to convolving the Fourier transform of your sine wave (your spike) with the fourier transform of your modulation distribution - which results in a spectrum that is no longer a spike, but has been somewhat smeared. Thus now you kill every frequency component except for the spike, you are throwing away all of the information regarding your modulation distribution and hence you get what you describe as distortion.&lt;br&gt;
&lt;br&gt;
The filter you need is not this very narrow spike that you are currently using, but one that corresponds/approximates to the Fourier transform of your amplitude modulated sine wave.&lt;br&gt;
&lt;br&gt;
Without knowing anything about the Modulation distribution, this is about as far as I can help.&lt;br&gt;
&lt;br&gt;
Regards&lt;br&gt;
&lt;br&gt;
Dave Robinson  </description>
    </item>
    <item>
      <pubDate>Tue, 04 Aug 2009 10:36:01 -0400</pubDate>
      <title>Re: Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670488</link>
      <author>juho salminen</author>
      <description>&quot;Dave Robinson&quot; &amp;lt;dave.robinson@somewhere.biz&amp;gt; wrote in message &amp;lt;h58vuv$aee$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &quot;juho salminen&quot; &amp;lt;jssalmi3@cc.hut.fi&amp;gt; wrote in message &amp;lt;h58mu4$2o2$1@fred.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi guys,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; I'm newbie with signal processing who is trying to implement fft to signal filtering. My problem is following: &lt;br&gt;
&amp;gt; &amp;gt; My signal is sinusoidial Wave with noise added in it. Wave is decreasing as time passes by.&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; My current filtering technique is following: I make FFT of signal, take highest peak from FFT, and cut every sample in frequency domain into 0 except highest peak. &lt;br&gt;
&amp;gt; &amp;gt; Then I just make ifft of signal. &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; This technique suits well for stationary sine wave, but when sine's amplitude changes rapidly with time, it seems that when signal is reversed back to time domain, some distortion to amplitudes of reversed signal is introduced. In my application, I need to get amplitudes of signals very accurately!&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Basicly, what I'm trying is to make filter, which would not make any phase delay for signal, and would fit for signals with different frequencies...&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Is there any other ways to do this kind of filter? &lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Could you guys also make some example code also? My signal processing knowledge is basicly 0&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; Thanks,&lt;br&gt;
&amp;gt; &amp;gt; &lt;br&gt;
&amp;gt; &amp;gt; -Juho&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Your basic problem appears to be that the moment you apply amplitude modulation, your signal ceases to be a pure sine wave. &lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; You are in effect taking your time domain sine wave and multiplying by your amplitude modification distribution. In the frequency domain this is equivelent to convolving the Fourier transform of your sine wave (your spike) with the fourier transform of your modulation distribution - which results in a spectrum that is no longer a spike, but has been somewhat smeared. Thus now you kill every frequency component except for the spike, you are throwing away all of the information regarding your modulation distribution and hence you get what you describe as distortion.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; The filter you need is not this very narrow spike that you are currently using, but one that corresponds/approximates to the Fourier transform of your amplitude modulated sine wave.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Without knowing anything about the Modulation distribution, this is about as far as I can help.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Regards&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Dave Robinson  &lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
Thank you for your response!&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
well, my signal could look like this (copy and paste to matlab): &lt;br&gt;
&lt;br&gt;
%------------------------------------------------------------------------------------&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;signalLength = 15000; &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;signalFrequency=100; &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;samplingFrequency=500;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;T = 1/samplingFrequency;      % Sample time&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;t = (0:signalLength-1)*T;     % Time vector&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;beginningPhase = pi;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;e = 2.7182818&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;dataVector = e.^(-2*pi*signalFrequency*t*0.001).*(100*sin(2*pi*signalFrequency*t)); &lt;br&gt;
&lt;br&gt;
originalNoise = 35*randn(1,length(t)); &lt;br&gt;
noisyDataVector = dataVector + originalNoise; &lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
%-------------------------------------------------------------------------------------------------&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&lt;br&gt;
I was trying to save some values near signal spike in frequency domain (more information for ifft) , but that makes distortions for amplitude due to noise...&lt;br&gt;
&lt;br&gt;
Is there a way to still better results ? &lt;br&gt;
&lt;br&gt;
Is there ANY way to filter this signal perrfectly or near perfectly? (for example, amplitude distortions always less than 1%)</description>
    </item>
    <item>
      <pubDate>Tue, 04 Aug 2009 10:48:02 -0400</pubDate>
      <title>Re: Filtering signal with rapid changes with FFT</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/257697#670491</link>
      <author>juho salminen</author>
      <description>Btw, why worst results appear in the beginning and end of the signal? I mean, after ifft has been done, &quot;modelled&quot; signal follows real signal very badly in the beginning and in the end of signal</description>
    </item>
  </channel>
</rss>

