Convert Matlab code to Simulink Model

8 visualizaciones (últimos 30 días)
Alex Harbach
Alex Harbach el 4 de Mayo de 2017
Editada: KL el 5 de Mayo de 2017
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

Respuestas (1)

KL
KL el 5 de Mayo de 2017
Editada: KL el 5 de Mayo de 2017
You need to write it into a function and then use it inside the matlab functions block of simulink library.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by