setting coefficients of particular frequency components to zero

Hello,
How to set the set the coefficients of particular frequency components to zero of a signal(for example coeffcients of from 1) 0.2Hz to 0.5Hz 2)0.8 to 6Hz frequency components coefficients to zero.
How to convert bakc iti into time domain after removing the frequency compoents coefficients.
Can I someone explain this with an example.
Thanks.

4 Comments

can someone explain a way to do this.
Stefan,
Can you explain what this signal looks like? Or, provide a simple test case?
You will want to cascade a filter with specific passbands/notches but how to implement this may depend on the original signal and perhaps what you want to do after processing.
You need to design two separate notch filters, then cascade them. Your resulting digital filter will filter them in the time domain, so no conversion back to the time domain will be necessary. See the documentation for the Signal Processing Toolbox for details.
Thankyou for your suggestions.
Can someone explain me how to do this for the attached data.

Sign in to comment.

Answers (1)

fs = 10; % Hz sampling rate (I made this up, you need to fix it)
filteredSignal = bandstop_butterworth(signal_data,[.2 .5],fs,1);
plot(signal_data,'b')
hold on
plot(filteredSignal,'r')

7 Comments

Thanks but how to filter out frequencies in between two limits from the same signal.
Should I need apply to bandstop filter function two times to filter the coefficients between 0.2 to 0.5 and 0.5 to 6Hz I mean like first filtering the signal with cutoff frequencies as 0.2 to 0.5 and second time filtering the first time filtered signal with cutoff frequencies of 0.8 to 6Hz? or is there anyother way to do this.
Yes, you could easily do
filtered1 = bandstop_butterworth(signal_data,[.2 .5],fs,1);
finalsignal = bandstop_butterworth(filtered1,[.6 .8],fs,1);
Your final signal should be the same no matter which frequency band you filter out first.
Thanks, I made this as you suggested
plot(signal_data);hold on;
filtered1 = bandstop_butterworth(signal_data,[.2 .35],100,2);
plot(filtered1,'-r');hold on;
finalsignal = bandstop_butterworth(filtered1,[.5 4],100,2);
plot(filtered1,'-g');
The final filtered signal is attached here.I don't understand why the baseline of the filtered signal is varying from -0.5 to 0.1 whereas the original has the its base at'zero' volts. If possible can you exaplin me the reason behind this.
It's because the original data has sharp corners at y=0. Sharp corners are made up of a lot of frequency components, and if you filter out some of those constituent frequencies the corners will not hold their shape. Sometimes the resulting green line will be above the original blue, other times it will be below.
Also note that you've plotted the filtered1 signal twice instead of plotting filtered1 and finalsignal.
Thanks for the explanation.
Can you please suggest me any solution for this(if there is one). Any alternate methods to filter only a particular frequency components.
I can't think of any physically-reasonable methods. Think about a mass oscillating on a spring. It naturally wants to make smooth arcs as it swings, and it would take energy to stop or sharply divert the mass as it moves. Your signal abruptly stops at y=0 as if someone put energy into stopping a mass. If you remove some frequency energy from your signal you'll essentially be taking away some of the energy that it would take to stop a swinging mass. If you want a brute-force method of keeping a filtered signal from going to zero, you can end the lines of code you've already created with
finalsignal(finalsignal<0)=0;

Sign in to comment.

Categories

Products

Asked:

on 6 Aug 2014

Commented:

on 6 Aug 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!