Tuesday 15 January 2013

matlab - Dynamically persistent variable -


I have a function that uses 2 consecutive variables. The function for the actual simultaneous block is input gcb I want to use the function on different blocks, so I believe the continuous variable declared with a name refers to the block name. function testbllock (blk) blkName = get_param (black, 'name') Constant black valve% it works for a block%, but I want something like this constant eval ( [BlkName 'value'])% does not work ... end

if you If you store the name of the block you want to do, then yes. If you want some data and a descriptive name, then I think that one structure works:

  data = struct ([blkName 'value'], []); Set_param (GCB, 'UserData', data);   

Then when you use the data,

  ud = get_param (gcb, 'userdata');   

Or you can use the global appadata storage:

   the setup data (0, [blkName ' Value '], data); Data = gate-data (0, [blacknum 'value']);   

Or you want, you can rewrite the function to create a variable by the name of yik , but I did the same thing. HH!

Edit I have used this code for a dialog callback multiple times, so I believe it will work, but I Do not fully understand your application: -)

Edit If you need data to continue each time you load the model, Code> UserDataPersistent parameter must be set to '<'> 'on' . It is an annoying, but clearly essential feature to choose what to forget about the model being closed and exit from the memory. Since this is a matter of your use, because the continuously variables in the ML-script will not work because when the matlab is finished then they forget. I believe that you will need to use it so that it will remain between matlab sessions.

No comments:

Post a Comment