How to use sparse in a matlab function block in simulink?
4 次查看(过去 30 天)
显示 更早的评论
Hey, any suggestions on how i can use the sparse function in simulink?
Example:
function y = fcn(u)
s = sparse(u)
y = full(u)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/154188/image.png)
Error:
Undefined function or variable 'sparse'.
Is there any workaround like writing a new sparse.m or sending the variables to workspace and back to use sparse?
Thanks for your help!
0 个评论
回答(2 个)
Wilmer Salto
2017-12-20
hi, i would like to know if you could use "sparse" in mulink ? i need a help
0 个评论
Walter Roberson
2017-12-20
Simulink does not support sparse as a signal attribute, so you can only use sparse within a MATLAB function (or Level II S function), and would have to convert any results back to full before allowing them to be output.
In order to use sparse inside of a MATLAB Function Block, you need to
coder.extrinsic('sparse');
Note that this will only work when Rapid Acceleration mode is turned off or is 'Normal'; for any higher level of acceleration, the internal code generation routines do not support sparse
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Sources 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!