Created
August 13, 2016 14:43
-
-
Save bc080401210/3eaf153a48078bf13fb28cd0c17365ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%%================================================================== | |
% | |
% IN THE NAME OF ALLAH, | |
% | |
%simple 50hz filter, to remove line noise, implemented in iir band stop | |
%filter method is butter worth filter | |
%% | |
% Aquaire a Clean Workspace; | |
clear all; | |
close all; | |
clc; | |
%% Simulation Parameters | |
Fs=1000; | |
F_org = 5; %original Signal Frequency | |
F_noise = 50; %noise frequency in Hz | |
T = 1/Fs; % Time Period | |
t= 0:T:1; % time signal to simulate all data | |
%% Creating Signals | |
org_x = sin(2*pi*F_org*t); | |
noise = sin(2*pi*F_noise*t); | |
mix_x = org_x + noise; | |
figure, plot(org_x),title('Orignial Signal Without Noise'); | |
figure, plot(noise), title('Noise Signal'); | |
figure, plot(mix_x), title('Mixed Signal, Included Noise'); | |
%% Creating Filter | |
d = designfilt('bandstopiir','FilterOrder',2, ... | |
'HalfPowerFrequency1',49,'HalfPowerFrequency2',51, ... | |
'DesignMethod','butter','SampleRate',Fs); | |
% Plot the frequency response of the filter. Note that this notch filter provides up to 45 dB of attenuation. | |
%fvtool(d,'Fs',Fs) | |
%% Filter Singal and plot final result; | |
y = filtfilt(d,mix_x); | |
figure, | |
plot(y),title('Filtered Output'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment