How to assign values to a matrix with a for loop when using PLC Coder?

2 次查看(过去 30 天)
Hello, I have a simulink model containing a user defined Matlab function that I want to generate PLC code from. Within that function I am assigning some values to a matrix uising a for loop.
Mini Code Example:
function y = fcn()
U = zeros(30, 30);
for i=1:2
U(i:30, i) = ones(31-i,i);
end
y = U;
When I check the subsystems compatibility for PLC Code Generation in simulink I get the following error:
"Variable-size arrays are currently disabled for code generation. Consider selecting the 'Support variable-size signals' option on the Configuration Parameters > Code Generation > Interface page."
Does anybody know how to solve this?
(When I write the assignment line by line by hand, it works perfectly fine. But in practice I have a lot more than 2 assignments. Thats why I want to use a for loop)
Thanks for any advice!!!

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Simulink PLC Coder 的更多信息

产品


版本

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by