Is it possible to open the default block dialog after a custom OpenFcn callback?

6 vues (au cours des 30 derniers jours)
I'd like to use the OpenFcn callback of a simulink block to run a script and then after the script is complete open the standard block dialog like normal. So far in the documentation I've only found references that any change to the OpenFcn callback will override the default behavior but no mention of how to pro grammatically open the default block dialog afterwards.
I've have created a workaround by placing code in the script which sets the OpenFcn callback of the current block to an empty string and then reopens it, followed by setting it back to calling the script. (see example below) This just feels like a really bad way to accomplish this and wondered if anyone knew of a better solution.
% Portion of code from my script that opens the default dialog
set_param(gcbh, 'OpenFcn', '')
open_system(gcbh)
set_param(gcb, 'OpenFcn', 'exampleScript;');
Thanks.

Réponse acceptée

TAB
TAB le 26 Mai 2018
Modifié(e) : TAB le 31 Mai 2018
In the OpenFcn of the block, run your script and the call open_system to open block dialog.
% In OpenFcn of block
exampleScript;
open_system(gcbh, 'parameter');
I think it should work. (I dont have access to Matlab to try this now)
  3 commentaires
TAB
TAB le 31 Mai 2018
I updated the answer. You need to call open_system with 'parameter' argument to open the block dialog.
% In OpenFcn of block
exampleScript;
open_system(gcbh, 'parameter');
Christopher Wallace
Christopher Wallace le 31 Mai 2018
Thanks Tabrez! This works great.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink Functions dans Help Center et File Exchange

Produits


Version

R2014a

Community Treasure Hunt

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

Start Hunting!

Translated by