'wn' is inferred as a variable-size matrix, but its size is specified as inherited or fixed.

19 views (last 30 days)
I built the model in SIMULINK according to MATLAN code, expecting to get Verilog. But putting the code into the MATLAB Function module generates an error.The code is an algorithm for an LMS filter.
'wn' is inferred as a variable-size matrix, but its size is specified as inherited or fixed. Verify 'wn' is defined in terms of non-tunable parameters, or select the 'Variable Size' check box and specify the upper bounds in the Size box.
I have tried the relevant error correction, but could not solve the problem.

Answers (1)

Lokesh
Lokesh on 29 Oct 2024 at 10:43
Hi Wang,
The error occurs because 'wn' and 'hn_0' depend on 'N', a tunable parameter.
To resolve this issue,go to the Model Explorer and check the "Variable Size" box for 'wn' and 'hn_0'.
Initialize 'x' and 'y' outside the loop to ensure they are defined for all execution paths.
Also, ensure that the length of zeros being concatenated is greater than 0 based on your definition of 'hn_0'.
Refer to the following code for an example check:
% Ensure dimensions match for concatenation
if N > size_hn(2)
hn_0 = [hn, zeros(1, N - size_hn(2))];
else
hn_0 = hn;
end
This check is necessary because 'hn_0' is dependent on the tunable parameter 'N', which can lead to issues if 'N - size_hn(2)' is smaller than expected in various cases.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!