How can I change parameters using the SET_PARAM in masked blocks or in the various Simulink Blocksets?

6 views (last 30 days)
How can I change parameters using the SET_PARAM in masked blocks or in the various Simulink Blocksets?
I want to change the values inside the various blocksets such as the DSP Blockset, Communications, Fixed-Point Blockset, or SimPower Systems.
Appendix A of Using Simulink shows how I can do this for built-in Simulink blocks like the Gain block, but what are the parameters for these other blocks?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
The blocks in the various blocksets are just masked blocks, and follow the same guidelines as those layed out for masked blocks in Appendix A of Using Simulink. Because of this, you can use the information on page A-22 to get and set a masked block's parameters. If you are not familiar with Masked blocks, they are described in Chapter 6 of Using Simulink, and basicallly allow you to create your own dialog box for a subsystem.
For example, if you have an LMS Block from the DSP Blockset in a model and it is the current block, you can type:
get_param(gcb,'MaskPromptString')
ans =
FIR filter length:
|Step-size, mu:
|Initial value of filter taps:
|Sample time
:|Use normalization
This string represents the different dialogs you see when you double click on the block. If you want to find out what values are entered for each of these dialogs, you can use
get_param(gcb,'MaskValueString')
ans =
32|.65|0.0|1|on
If you want to set these values so that the sample is .01 you can type:
set_param(gcb,'MaskValueString', '32|.65|0.0|.01|on')
One limitation is that you have to specify all of the values.
The syntax:
get_param(gcb,'MaskVariables')
ans =
n=@1;mu=@2;ic=@3;ts=@4;normalized=@5;
defines what these values correspond to. For example, this means that the value in the first dialog gets assigned to the variable n and sent to the subsystem, the second dialog goes to the variable mu, and so on. If you choose Edit->Look Under Mask on this block, you can see that these variables are used in the subsystem. Again, this is described in more detail in Chapter 6 and on A-22.

More Answers (0)

Products

Community Treasure Hunt

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

Start Hunting!