Is possible to change Sample time in signal builder programmatically?

25 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Tobias Huth
Tobias Huth il 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

Più risposte (3)

Arnauld Disableu
Arnauld Disableu il 11 Ago 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 il 5 Ott 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 il 24 Apr 2018
Modificato: Arun Kumar Misra il 3 Lug 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 Commento
Tobias Huth
Tobias Huth il 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.

Accedi per commentare.

Categorie

Scopri di più su Simulink Environment Customization in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by