Main Content

Explore Measurable and Tunable Model Elements

Open the model CapiSigsParams.

capiMdl = "CapiSigsParams";
open_system(capiMdl);

CapiSigsParams model.

Simulate Model

The Sine Wave block generates a signal, which is branched. Each of the two Gain blocks amplifies one of the branches. The output of the Gain blocks are measurable signals. During model simulation, the Scope block displays these two signals.

Simulation the model and see how the scope plots the two amplified signals.

sim(capiMdl)

Scope displays the two amplified signals.

Change Gain Values

The gain coefficients are specified as the model parameters Amp_coef_1 and Amp_coef_2. These can be tuned to change the amplitude of the amplified signals.

Use the Model Explorer to change the gain coefficient values to 3 and -4 (see Edit and Manage Workspace Variables by Using Model Explorer).

Model Explorer window. The value of Amp_coef_2 is 2, and the value of Amp_coef_1 is being set to -1.

Alternatively, you can change the gain coefficient values programmatically by entering these commands in the Command Window:

workSpace = get_param(capiMdl,"ModelWorkspace");
workSpace.getVariable("Amp_coef_1").Value = 3;
workSpace.getVariable("Amp_coef_2").Value = -4;

Simulate the model again and observe how the amplitudes of the amplified signals change after modifying the gain coefficient values.

sim(capiMdl)

Scope displays the two amplified signals, denoting the change in amplitude with the revised gain coefficients.

In the next step of the example, you configure the model to include the C API elements for signals and parameters in the generated model code. To continue to the next step of the example, use this in the Command Window:

openExample("simulinkcoder/CapiSigsParams02Example")