Opening the book…
Now let us build a model for a slightly more interesting expression:
2X + 3Y
If X = 10 and Y = 20, the result should be:
2(10) + 3(20) = 20 + 60 = 80
Blocks needed:
- Two Constant blocks
- Two Gain blocks
- One Sum block
- One Display block
A Gain block multiplies an input by a constant value. In this example, one Gain block multiplies X by 2 and the other Gain block multiplies Y by 3.
Build the model using these steps:
1. Define X and Y in MATLAB or in the model initialization callback.
2. Use one Constant block for X and one Constant block for Y.
3. Connect X to a Gain block with gain value 2.
4. Connect Y to a Gain block with gain value 3.
5. Connect both Gain block outputs to a Sum block.
6. Connect the Sum block to a Display block.
7. Run the model.
This page titled 11.8: Example- Evaluating an Expression was last modified on Tue, 30 Jun 2026 02:11:50 GMT and is shared under a CC BY-NC-SA license and was authored, remixed, and/or curated by Zara Noroozi.
The book could not be loaded just now.