Error while generating HDL code from Matlab: variable-size matrix type is not supported for HDL code generation.
1 次查看(过去 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.
0 个评论
回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!