change code of a matlab function within a simulink model with a script
1 view (last 30 days)
Show older comments
I use the find_system command within a Matlab script to get the identifier of a Matlab function within a Simulink model. Now I want to change the sourcecode of this Matlab function out of the Matlab script. I tried set_param(identifier,parameter) but I can't find the rigth parameter. Which command do I have to use?
0 Comments
Answers (1)
Brandon Eidson
on 6 Jan 2017
Hey Bernhard, I am not immediately aware of a way to accomplish precisely what you are asking. I can think of two close alternatives.
1) You may could use a "Level-2 MATLAB S-Function" block and programmaticaly change the MATLAB S-Function to which it was referring (the Dialog Parameter "FunctionName").
set_param(handleToBlock, 'FunctionName', 'newFunction');
This would require all the S-functions to have the same input and output properties. You can execute the command "sfun_demos" to view several examples of using S-functions.
2) You could use a "Variant Subsystem" block. Inside it could be several subsystems, each with a MATLAB function block inside. You could then programmatically update the conditions to vary which subsystem was enabled. You can read more about variant subsystems at the documentation linked to below.
See Also
Categories
Find more on Simulink Functions in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!