matlab - Edit displayed text in a simulink mask when the block gets initialized -


i have cell array of strings. want display these strings text in mask of subsystem, not on block of subsystem itself. no problem, if have hit aplay button between giving strings , when displayed. perhabs callback function make step in final version.

the cell array different subsystem subsystem.

i made picture. on dropbox. picture better understanding

in actual mask, cell array generated object of custom class. first give subsystem object whith cell array. initialize the block , strings of cell array should desplayed in mask. because these strings options in subsystem. can type options edit fiel in mask. second part isn't problem. problem display text in cell array in mask.

thanks help.

here's example uses single string, should relatively easy modify work cell array of strings.

enter image description here

consider simple model (top left of image) contains masked subsystem. mask contains one parameter , 1 text control (as shown in mask editor , mask itself).

of particular significance is

  1. the evaluate , tunable attribute of parameter have been de-selected. (you may want these selected, , rest of example should still work.)
  2. the name property of text control has been specified 'textcontrol' (this tag used later).

on initialization pane of mask editor, enter following code:

% mask object mo = get_param(gcb,'maskobject'); % text object tc = mo.getdialogcontrol('textcontrol'); % change string tc.prompt = mo.parameters(1).value; 

again, note above works if there one parameter. if have more 1 control on mask you'll need modify above correct string (or cell array of strings) correct parameter.

you need execute following @ matlab command line (after selecting subsystem block left clicking on it)

set_param(gcb,'maskselfmodifiable','on'); 

which tells simulink mask allowed change block.

with of above, if enter string edit box on mask, press apply (or have initialization occur @ other time), entered string appear in text area of mask.


Comments

Popular posts from this blog

apache - setting document root in antoher partition on ubuntu -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

php - laravel retrieving profile firstname from model returns Object of class Illuminate\Database\Eloquent\Builder could not be converted to string -