Editing the Code of a “MATLAB Function” Block in Simulink Programmatically

与世无争的帅哥 提交于 2019-12-06 09:46:19

(As requested by @Ander Biguri, I've moved a solution that worked for me to a separete answer post. If anyone has an alternative/better approach, please feel free to post it as well)

Well, it seems that this question was asked here before. (perhaps formulated differently though?) I've managed to solve my issue using the following code:

sf = sfroot()
block = sf.find('Path','my_system/my_func','-isa','Stateflow.EMChart');
block.Script = sprintf('function y = fcn(u)\n%%#codegen\n\ny = 2 * u;')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!