Is possible to change Sample time in signal builder programmatically?

35 views (last 30 days)
Hi,
I need to change the sample time parameter inside a signal builder block. Manually can be changed in Signal Builder->File->Simulation Options. Using set_param command, I've not found any object paramter that allows to change it. Is there any way to do it?
Thanks.

Accepted Answer

Tobias Huth
Tobias Huth on 21 Feb 2018
The GUI setting is overridden by setting the sample-time of the 'FromWorkspace' inside the signal builder BUT it is not displayed and one of the masks callbacks sets the value from the menu. Thus the value is set to the one specified on the GUI.
So,yes, there seems to be no way to set these values from a skript...
But thanks for the answer!
- Tobias

More Answers (3)

Arnauld Disableu
Arnauld Disableu on 11 Aug 2021
Hello
Facing the same problem I did some research.
No major improvement though. The File/Simulink options GUI is still not updated and still prevails.
Common commands :
figH=get_param(gcb,'UserData'); % with gcb the signal builder block
UD=get(figH,'UserData');
To lauch the GUI :
sigbuilder('simOpts', figH [,UD]); % UD is optionnal. Seems that this function is interested by UD.common.
To set underlying FromWorkspace block parameters :
set_param(UD.simulink.fromWsH, 'SampleTime', '-1')
set_param(UD.simulink.fromWsH, 'OutputAfterFinalValue', 'Holding final value');
set_param(UD.simulink.fromWsH, 'Interpolate', 'off');
To close the signal builder window :
sigbuilder_block('close');
Hope this will help.
Best regards
Arnauld Disableu

ES
ES on 5 Oct 2017
First: Signal Builder is actually a masked from workspace block. So you can find the underlying from workspace block using find_system and then set its 'SampleTime' property.
Second: Apart from storing this info in 'SampleTime' a simulink model also saves the full signal builder data in some obfuscated form inside the model. I think this is what shows in the GUI. This can't be changed in my opinion due to the obfuscation. So the GUI setting is never overridden.

Arun Kumar Misra
Arun Kumar Misra on 24 Apr 2018
Edited: Arun Kumar Misra on 3 Jul 2018
i was able to do this, but this doesn't change value on GUI, but it works set_param(strcat(TH_Model_Name,'/Stimuli/Input_Vectors/FromWs'),'SampleTime',get_param(model,'FixedStep')); set_param(strcat(TH_Model_Name,'/Outputs/Reference_Vectors/FromWs'),'SampleTime',get_param(model,'FixedStep'));
  1 Comment
Tobias Huth
Tobias Huth on 26 Apr 2018
Hello Arun Kumar Misra,
can you please point out, what "Delphi_TH_Model_Name" and the other blocknames (?) in your code snippet refer to? The signal builder block does not have underlying blocks of the names in your answer.
I assume, that you are setting the underlying FromWorkspace's parameter. This works until you open the signal builder block again. When you open the GUI of the signal builder, the parameter set with set_param is reset to the value on the GUI.
So a workaround could be to have a callback (e.g. at model update), that checks the FromWorkspace's sample time parameter and sets it to the desired value, if it it was reset.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!