Introduction to Simulink with Engineering Applications

This chapter is an introduction to the User-Defined Functions Library. This is the fifteenth library in the Simulink group of libraries and contains the blocks shown below. We will describe the function of each block included in this library and we will perform simulation examples to illustrate their application.


The Fcn block applies a specified expression to its input denoted as u. If u is a vector, u(i) represents the ith element of the vector; u(1) or u alone represents the first element. The specified expression can consist of numeric constants, arithmetic operators, relational operators, logical operators, and the math functions abs, acos, asin, atan, atan2, ceil, cos, cosh, exp, fabs, floor, hypot, In, log, log10, pow, power, rem, sgn, sin, sinh, sqrt, tan, and tanh.
It can be shown that the solution of the differential equation
| (16.1) | |
is
| (16.2) | |
where the constants k 1 and k 2 can be evaluated from the initial conditions. Then we can compute and display any value of y by specifying t, k 1, and k 2, using the model shown in Figure 16.1.
For the model of Figure 16.1 we specified u(1) = t = ?/6, u(2) = k 1 = -1, u(3) = k 2 = -3, and in MATLAB's Command window we entered:
u(1)=pi/6; u(2)=-1; u(3)=-3;y=-(1/4)*cos(2*u(1))*log(sec(2*u(1))+tan(2*u(1)))+v(2)*cos(2*u(1))+v(3)*cos(2*u(1));

The MATLAB Fcn