10.6. Using Variables from MATLAB

Some variables such as ‘gain’ may be calculated in MATLAB and then used in a Simulink model. This can be done by simply using the same variable name in the Simulink model as well as in the MATLAB. In this example, the gain value is replaced by variable ‘K’ in place of a constant numerical value in the dialog box of Gain as shown in Figure 10.21.

Figure 10.21. Gain Variable Defined as ‘K

Now, the Gain block in the model shows the variable ‘K’ rather than a number, as shown in Figure 10.22.

Figure 10.22. Model Showing the Variable ‘K’ in Gain Block

The value of the variable ‘K’ can ...

Get MATLAB® and Its Applications in Engineering: [Based on MATLAB 7.5 (R2007b)] now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.