Error: The sample time for any variable-size signal must be discrete
39 次查看(过去 30 天)
显示 更早的评论
Hi,
I have the following code within the MATLAB Function Block Editor (in the Matlab function found in the user-defined library in simulink). The size of output y depends on the input u.
function y = fcn(u)
%#codegen
assert(u<=10);
y = zeros(1,u);
for i = 1:u
y(i) = 3;
end
end
Also, in the Ports and Data Manager, I have also checked the Variable Size option for output y, and entered a size of 10 in the Size field.
However, running the simulation generated the error: The signal at input port 1 of 'untitled/Display' is a variable-size signal with a nondiscrete sample time. The sample time for any variable-size signal must be discrete.
May I know what is going on and how do I go about solving it? I would greatly appreciate any help or advice. Thanks in advance!
0 个评论
回答(2 个)
S An
2018-4-29
Hi, I met this problem today. I solved it by creating a new blank "matlab function" in simulink and copying the code from the old one. Hope it's useful!
1 个评论
amal elkouche
2019-11-10
Hi S An, I also met this problem, can you tell me how can I connect the ports of the new matlab function with the model?
Thank you in advance
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Code Generation and Deployment 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!