- The first assignment to a variable defines its, size, class, and complexity.
- See Best Practices for Defining Variables for C/C++ Code Generation.
- You cannot reassign variable properties after the initial assignment except when using variable-size data or reusing variables in the code for different purposes.
- See Reassignment of Variable Properties."
A Matlab Function: in Matlab Function Block Vs. in Matlab Editor
1 次查看(过去 30 天)
显示 更早的评论
Hi, I'm using a matlab function (waypoints.m) to generate an array of waypoints. The input arguments are the starting and ending points as two [1x3] arrays. The code works fine when I run it in the editor. But when I create a Simulink Matlab function block, I call the function (waypoints.m) in it, and I input the starting and ending points as two [1x3] arrays in constant blocks, I always get many errors repeated in some parts of the code, errors include:
- Index expression out of bounds,
- Function call failed, Undefined function or variable 'xxxx'. The first assignment to a local variable determines its class,
- Simulink cannot determine sizes and/or types of the outputs for block 'MATLAB Function' due to errors in the block body, or limitations of the underlying analysis. The errors might be inaccurate. Fix the indicated errors, or explicitly specify sizes and/or types for all block outputs....
Why does it work perfect in editor and not in a function block? Any help ?
0 个评论
回答(1 个)
Walter Roberson
2018-1-20
"The MATLAB Function block generates efficient embeddable code based on an analysis that determines the size, class, and complexity of each variable. This analysis imposes the following restrictions:
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Simulink Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!