Clear Filters
Clear Filters

i have a signal with many frequencies. how to remove a particular frequency and reconstruct the signal.

106 views (last 30 days)
I heard about doing fft and then ifft but don't know how to implement. for example, the frequencies are close to each other as ( 0.1282 0.5128 0.8974 1.1538) now, how can I remove only 0.5128 Hz frequency and reconstruct the signal.
I've attached my data file and frequency finding code.

Answers (2)

Star Strider
Star Strider on 3 Sep 2017
Try this filter:
signal = load('datee.txt'); % Signal Vector
signal = detrend(signal,0);
Fs = 10; % Sampling Frequency (Hz)
Ts = 1/Fs; % Sampling Interval (sec)
tv = linspace(0, 1, numel(signal))*Ts; % Time Vector
Fn = Fs/2; % Nyquist Frequency (Hz)
Wp = [0.503 0.523]/Fn; % Passband Frequency (Normalised)
Ws = [0.483 0.543]/Fn; % Stopband Frequency (Normalised)
Rp = 1; % Passband Ripple (dB)
Rs = 50; % Stopband Ripple (dB)
[n,Ws] = cheb1ord(Wp,Ws,Rp,Rs); % Filter Order
[z,p,k] = cheby1(n,Rs,Ws,'stop'); % Filter Design
[sossb,gsb] = zp2sos(z,p,k); % Convert To Second-Order-Section For Stability
figure(5)
freqz(sossb, 2^16, Fs) % Filter Bode Plot
filtered_signal = filtfilt(sossb, gsb, signal); % Filter Signal
figure(6)
subplot(2,1,1)
plot(tv, signal)
grid
subplot(2,1,2)
plot(tv, filtered_signal)
grid
This designs a narrow Chebyshev Type I bandstop filter. Experiment with the filter stopbands and passbands to get the result you want.
To use it with my previous code, append it to the end of my previous code, and substitute this assignment:
signal = load('datee.txt'); % Signal Vector
with this one:
signal = filtered_signal;
  4 Comments

Sign in to comment.


Image Analyst
Image Analyst on 3 Sep 2017
Edited: Image Analyst on 3 Sep 2017
Find the index for that frequency, and set it to 0, then call ifft().
See attached demo (though it's for a 2-D image, not a 1-D signal though the concept is the same).
  1 Comment
rohith bharadwaj
rohith bharadwaj on 4 Sep 2017
thanks for the help. but can I get the code like, enter the frequency to remove: like scanf in C and then get the reconstructed signal by removing this frequency

Sign in to comment.

Categories

Find more on Get Started with Signal Processing Toolbox in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!