Convert Matlab code to Simulink Model
8 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I have just recently finished writing a script for a LMS filter to filter out white noise from an audio file. I would like to know if there is a way for me to convert this script into a Simulink model so I can see how the filter works in real-time. Here is the code:
signal = yes, fs;
noise = white_noise, fs1;
% Define Adaptive Filter Parameters
filterLength = 32;
weights = zeros(1,filterLength);
step_size = 0.004;
% Initialize Filter's Operational inputs
output = zeros(1,length(signal));
err = zeros(1,length(signal));
input = zeros(1,filterLength);
% For Loop to run through the data and filter out noise
for n = 1: length(signal)
%Get input vector to filter
for k= 1:filterLength
if ((n-k)>0)
input(k) = noise(n-k+1);
end
end
output(n) = weights * input'; %Output of Adaptive Filter
err(n) = signal(n) - output(n); %Error Computation
weights = weights + step_size * err(n) * input; %Weights Updating
end
0 Kommentare
Siehe auch
Kategorien
Mehr zu Sources finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!