Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Self-Modifying Blocks Copy Contents

38 views
Skip to first unread message

Richard

unread,
Oct 21, 2009, 6:58:06 PM10/21/09
to
I have a block that I would like to have change based on the mask parameters of that block. I have a low level block that will need have the logic repeated multiple times based on the number of wheels specified as a parameter. My idea is to have the user simply put in how many wheels there are as a block parameter, and have the block copy the underlying logic that many times and update the number of inputs and outputs. This will simplify model building for the user in that they won't have to drag over 18 blocks if there are 18 wheels, they would just specify 18 wheels as a parameter, and the block would automatically take care of itself. I was thinking of doing this in the initalization commands of the mask editor. I am not sure how to best accomplish this however. Any help would be greatly appreciated.

Thanks,

Richard

Arnaud Miege

unread,
Oct 22, 2009, 4:15:05 AM10/22/09
to

"Richard " <richard....@craneaerospace.com> wrote in message
news:hbo3lu$6pa$1...@fred.mathworks.com...

Not sure it will work, but you probably need to use add_block and add_line
with a combination of get_param and set_param in the initalization tab of
the mask editor.

Look at the doc for a simple example:
http://www.mathworks.com/access/helpdesk/help/toolbox/simulink/ug/bryfvlv-1.html

HTH

Arnaud


Riccardo

unread,
Oct 22, 2009, 10:42:04 AM10/22/09
to
"Arnaud Miege" <arnaud...@nospam.mathworks.co.uk> wrote in message <hbp4aa$pj7$1...@fred.mathworks.com>...

Hi,
in addition to Arnaud's hints and TMW's docs, I'd also suggest:
1) define a "hidden" - i.e. not shown in the GUI - mask parameter to store the "status" of the block editing/modifying queries, in order to prevent the m-script/function in the mask initialization from re-editing the block every single time it runs (side effects: surely slow response but potentially block/model corruption) and implement some appropriate logic to handle it;
2) careful if you make use of any other mask callback - particularly from parameter fields;
3) consider whether the functionality you'd like to offer is better managed via an s-function, where specific methods allow you to handle the block properties (I/O , interface parameters, state variables, etc.) quite naturally, without the need of "redrawing" a masked subsystem.

HTH
Riccardo

Richard

unread,
Oct 22, 2009, 11:41:21 AM10/22/09
to
"Riccardo" <no...@nospam.org> wrote in message <hbpqvs$hp6$1...@fred.mathworks.com>...

Thanks for the help. I hadn't considered S-Functions, but will take a look at that. I was also considering just having the low level function as a block in a library, and then writing a script that uses add_block to add the correct number of blocks. This might be best because it is likely that the number of wheels will be defined as a variable rather than through the user inputting the value manualy.

Richard

0 new messages