low pass filter coding that received white noise as a input

7 views (last 30 days)
I want to create a low pass filter exactly
w0/ (s+ w0)
This filter received white noise of spectural density as i/p and give an output.
Note: w0 is the natural frequency of the system.

Answers (1)

William Rose
William Rose on 29 May 2022
You have specified a low pass filter with a cutoff frequency of radians per unit time. Since you did not specify a filter order, or other filter requirements, we will use the simplest low pass filter:
where , where is the sampling rate, in samples per unit time.
Example: Sampling rate = . Desired lowpass filter cutoff frequency = radians/s.
%% Define constants
fs=100; %sampling rate (Hz)
w0=10*2*pi; %cutoff frequency (radians/s)
N=100; %number of points in signal
%% Define input signal and time vector
t=(1:N)/fs; %time vector
x=randn(1,N); %input signal=Gaussian white noise
%% Filter the input signal
alpha=w0/(w0+fs);
y=zeros(1,N); %allocate array for y
y(1)=0; %initial value for y
y(2:N)=alpha*x(2:N)+(1-alpha)*y(1:N-1); %filter the signal
%% Plot results
plot(t,x,'-r',t,y,'-b');
xlabel ('Time (s)'); legend('Input','Output'); title('Lowass filter')
Good luck.

Community Treasure Hunt

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

Start Hunting!