To demonstrate parameter setting and linking mechanisms, let us set the model instance parameter values of our example. Different methods for achieving the same result are demonstrated here such as linking and export.
First, you must set the actual parameters of the Ramp instance in the Sine Generator module.
You have now set the actual parameter step of the Ramp instance to an expression that contains the formal model parameter names. This realizes indirect linking between the Ramp parameter and the Sine Generator parameter.
|(a) Sine Generator module properties||(b) Ramp instance properties|
The next step is to set the actual parameter of the Sine Generator instance in the Sine Modulator model. The Sine Generator has two actual parameters Frequency and SampleRate. Since the sample rate should be constant in the whole system model hierarchy it should be settable on the system model level. The Frequency of the sine modulator should be a parameter on the system model level. Therefore, it is necessary to export the SampleRate and Frequency parameters to the next higher model level. Follow the steps below to export these two parameters.
The green arrows in both fields indicate that these parameters are successfully exported.
By exporting the actual parameters Frequency and SampleRate of the Sine Generator instance, you have automatically created the two formal model parameters of the Sine Modulator module.
|(a) Sine Modulator module properties||(b) Sine Generator instance properties|
The last step is to create the system model parameters. You need two different frequencies; one for the signal frequency, and a carrier frequency for the sine modulator as well as a system model parameter for the sample rate.
You have created the system parameters SignalFrequency, CarrierFrequency, and SampleRate by exporting the model instance parameter. However, the setting of the actual parameter SampleRate of the Sine Modulator model instance was realized by linking the parameter to the existing system model parameter SampleRate. Now you can control the whole model using system parameters. By setting their Scope to External in the System Properties window, you can control them directly in the Simulation Properties window (see Simulation with MLDesigner).
The next step is to connect the model instances.