Error while generating HDL code from Matlab: variable-size matrix type is not supported for HDL code generation.

13 ビュー (過去 30 日間)
While trying to generate verilog file using HDL Coder, I got the following error in the HDL Code Generation step.
My function “MPC_track” is to implement an MPC controller, the input and output of the function are both scalars or vectors, no matrices. I noticed that the problem could be in places like the following, where both the p_ni, j_ni and k_ni values are changed in the loop. I am very confused, because the size of the A_ni matrix is fixed, there should be no problem.
for p_ni = 1:N_ni-1
% Find the pivot row for column p
[~,j_ni] = max(abs(A_ni(p_ni:N_ni,p_ni)));
% Interchange row p and j
C_ni = A_ni(p_ni,:);
A_ni(p_ni,:) = A_ni(j_ni+p_ni-1,:);
A_ni(j_ni+p_ni-1,:) = C_ni;
d_ni = R_ni(p_ni);
R_ni(p_ni) = R_ni(j_ni+p_ni-1);
R_ni(j_ni+p_ni-1) = d_ni;
% if A(p,p)==0
% 'A is singular. No unique solution';
% break
% end
% Calculate multiplier and place in subdiagonal portion of A
for k_ni = p_ni+1:N_ni
mult_ni = A_ni(k_ni,p_ni)/A_ni(p_ni,p_ni);
A_ni(k_ni,p_ni) = mult_ni;
A_ni(k_ni,p_ni+1:N_ni) = A_ni(k_ni,p_ni+1:N_ni) - mult_ni * A_ni(p_ni,p_ni+1:N_ni);
end
end
I am new to the HDL coder, kindly help me resolve the issue, thanks!
I have uploaded the function file "MPC_track.m" and the test bench file "simulation.m" in the attachment.

回答 (1 件)

Yichuan Wang
Yichuan Wang 2022 年 2 月 23 日
Could somebody help me handle this problem? Very Thanks.

カテゴリ

Help Center および File ExchangeCode Generation についてさらに検索

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by