フィルターのクリア

Could not determine the size of this expression

4 ビュー (過去 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 Center および File ExchangeArray and Matrix Mathematics についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by