Could not determine the size of this expression

4 visualizaciones (últimos 30 días)
wang
wang el 13 de Abr. de 2023
Comentada: Walter Roberson el 10 de Mayo de 2023
I want to convert the LMS filter algorithm to Verilog, but need to solve the problem of variable matrix. The point is, why does MATLAB think this piece of code is mutable? How can I solve this problem?
Verilog does not Support mutable matrices, so I uncheck Support variable_size arrays.
function [yn,W,en]=LMS(xn,dn,M,mu)
itr = length(xn);
en = zeros(itr,1);
W = zeros(20,100);
for k = M:itr
x = xn(k:-1:k-M+1);
y = W(:,k-1).' * x;
en(k) = dn(k) - y ;
W(:,k) = W(:,k-1) + 2*mu*en(k)*x;
end
yn = inf * ones(size(xn));
for k = M:length(xn)
x = xn(k:-1:k-M+1);
yn(k) = W(:,end).'* x;
end
could not determine the size of this expression. Function 'LMS/MATLAB Function' (#90.543.553), line 19, column 12: "k:-1:k-M+1" Launch diagnostic report.
  4 comentarios
Fangjun Jiang
Fangjun Jiang el 10 de Mayo de 2023
Editada: Fangjun Jiang el 10 de Mayo de 2023
This is a MATLAB Function block in Simulink. M is an input to the MATLAB Function block. At each simulation step, M could change, thus the size of x could change.
Does M change value during the simulation?
Walter Roberson
Walter Roberson el 10 de Mayo de 2023
Odd... I only count 17 lines of code, but the error is on line 19. (I was trying to determine if the error was on the first assignment to x or the second assignment.)
If the error was on the second assignment, then maybe it might go away if you use a different variable instead of x in the second loop, so that it does not see the second loop as a redefinition of x.
It looks to me as if the two loops could be merged. The first loop is M:itr but iter = length(xn), so when the second loop is M:length(xn) that is really the same upper bound -- it is confusing that itr was not used there as well.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Computer Vision with Simulink en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by