building simulink model from command window

2 次查看(过去 30 天)
Hello World!
I am trying to build a model via command window.
In this task I have a problem with the next command; add_block('built-in/ToWorkspace', 'untitled/name1', 'Position',[0 0 30 30]), because it changes the default block parameter "Limit data points to last:" from "inf" to 1000. Why is that?
Is there a command to change this parameter to "inf"? I've been looking for a solution but I cannon even find the parameter name, so that I could change it with the "set_param" command..
Thank You!

采纳的回答

Jason Moore
Jason Moore 2015-2-7
To programmatically change the a block parameter you can use get_param and set_param to change parameters of Simulink blocks. The parameter you are looking for is MaxDataPoints. The following commands should get you what you are looking for.
block_handle = add_block('built-in/ToWorkspace', 'untitled/name1', 'Position',[0 0 30 30])
set_param(block_handle,'MaxDataPoints','inf')
Another helpful tip is after you add the block you have an optional output that would be the block handle. I used this handle with set_param to change the desired parameter. You can also pass this handle to the command inspect to see a list of changeable parameters
inspect(block_handle)

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programmatic Model Editing 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by