strcat not supported for code generation simulink
显示 更早的评论
I have a need for a function block that can not be made with existing simulink blocks.
I built a very simply simulink model that uses a user defined function. aka a matlab typical .m function
inside there is the strcat function.
Im getting an error that says strcat not supported by code generation.
I have seen this time and time again not just with strcat but with basically anything.
Can anyone tell me what is going on? it seems as if you can basically use not "common" matlab features to build a simulink block
采纳的回答
更多回答(1 个)
Walter Roberson
2021-8-25
1 个投票
it seems as if you can basically use not "common" matlab features to build a simulink block
Yes, that is correct. Simulink is much more restricted than basic MATLAB is.
With regards to strcat:
- if any input is a string object, the output is a string array. Sizes of non-scalar arguments must match and output is same size as the non-scalar input
- if no input is a string object, but at least one input is a cell array of characters, the output is a cell array of characters. Sizes of non-scalar arguments must match, and output is same size as the non-scalar input
- otherwise the output is a character array. The number of rows must match for entries with more than one row, and the output has that number of rows
So... in order for Simulink to be able to predict the size and data types of the outputs, it would have to know these rules and analyze the inputs. But if any of the inputs are passed in, then Simulink might not know the datatype ahead of time, and so be unable to statically decide size and datatype.
Simulink "string" signals also turn out not to be the same as character vectors or MATLAB string objects... https://www.mathworks.com/help/simulink/ug/simulink-strings.html
strjoin() on the other hand can predict that the output is character vector, always. https://www.mathworks.com/help/matlab/ref/strjoin.html
... and these differences are important in Simulink. MATLAB has the luxury of being able to dynamically change datatypes and size, but Simulink has no flexibility on changing data type, and a number of restrictions on changing size.
Simulink with acceleration is most targetted at configurations where you are not doing any dynamic memory allocation, or at most you have a restricted maximum call stack.
类别
在 帮助中心 和 File Exchange 中查找有关 String 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!