Why do I receive an error about number of output arguments when using an MATLAB file S-function in Simulink 6.0 (R14) which simulates correctly in earlier versions?
2 次查看(过去 30 天)
显示 更早的评论
I receive an error about number of output arguments when using an MATLAB file S-function in Simulink 6.0 (R14) which simulates correctly in earlier versions.
I have a model which contains an MATLAB file S-function created in MATLAB 6.5.1 (R13SP1). This function simulates with no errors when ran in Simulink 5.1 (R13SP1) and earlier versions. However, when I attempt to simulate the same model and S-function in Simulink 6.0 (R14), I receive the following error:
Error in 'untitled/S-Function' while executing MATLAB file
S-function 'my_sfun', flag = 0 (initialize), at start
of simulation. MATLAB error message:
One or more output arguments not assigned during call
to '$MATLAB\work\my_sfun.m (my_sfun)'
(where $MATLAB = the MATLAB root directory on your machine)
采纳的回答
MathWorks Support Team
2010-8-5
In Simulink 6.0 (R14), the variable str must be initialized in the case where flag = 0 (Initialization) when it was not necessary in earlier versions. As a workaround, try adding:
str = [];
to the case where flag = 0 in your MATLAB file S-function. Also, you can use
[sys,x0,str, ts] = mdlInitializeSizes;
and declare str in mdlInitializeSizes. This is the approach given in the example S-function template sfuntmpl.m.
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Environment Customization 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!