Error: The sample time for any variable-size signal must be discrete

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!

답변 (3개)

S An
S An 2018년 4월 29일

1 개 추천

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

Siva Shankar
Siva Shankar 2019년 3월 4일
편집: Siva Shankar 2019년 3월 4일
S An that was a silly answer.Hope it's not useful

댓글을 달려면 로그인하십시오.

amal elkouche
amal elkouche 2019년 11월 10일

0 개 추천

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

카테고리

도움말 센터File Exchange에서 General Applications에 대해 자세히 알아보기

질문:

2012년 3월 3일

편집:

DGM
2025년 3월 27일

Community Treasure Hunt

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

Start Hunting!

Translated by