Thread Subject: Self-Modifying Blocks Copy Contents

Subject: Self-Modifying Blocks Copy Contents

From: Richard

Date: 21 Oct, 2009 22:58:06

Message: 1 of 4

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

Subject: Self-Modifying Blocks Copy Contents

From: Arnaud Miege

Date: 22 Oct, 2009 08:15:05

Message: 2 of 4


"Richard " <richard.schwartz@craneaerospace.com> wrote in message
news:hbo3lu$6pa$1@fred.mathworks.com...
>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
>

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

Subject: Self-Modifying Blocks Copy Contents

From: riccardo

Date: 22 Oct, 2009 14:42:04

Message: 3 of 4

"Arnaud Miege" <arnaud.miege@nospam.mathworks.co.uk> wrote in message <hbp4aa$pj7$1@fred.mathworks.com>...
>
> "Richard " <richard.schwartz@craneaerospace.com> wrote in message
> news:hbo3lu$6pa$1@fred.mathworks.com...
> >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
> >
>
> 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
>

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

Subject: Self-Modifying Blocks Copy Contents

From: Richard

Date: 22 Oct, 2009 15:41:21

Message: 4 of 4

"Riccardo" <nothx@nospam.org> wrote in message <hbpqvs$hp6$1@fred.mathworks.com>...
> "Arnaud Miege" <arnaud.miege@nospam.mathworks.co.uk> wrote in message <hbp4aa$pj7$1@fred.mathworks.com>...
> >
> > "Richard " <richard.schwartz@craneaerospace.com> wrote in message
> > news:hbo3lu$6pa$1@fred.mathworks.com...
> > >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
> > >
> >
> > 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
> >
>
> 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

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

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
simulink Richard 21 Oct, 2009 18:59:08
selfmodifying b... Richard 21 Oct, 2009 18:59:08
rssFeed for this Thread

Contact us at files@mathworks.com