Could not determine the size of this expression

조회 수: 5 (최근 30일)
wang
wang 2023년 4월 13일
댓글: Walter Roberson 2023년 5월 10일
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
Fangjun Jiang
Fangjun Jiang 2023년 5월 10일
편집: Fangjun Jiang 2023년 5월 10일
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 2023년 5월 10일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Computer Vision with Simulink에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by