Stateflow User's Guide Previous page   Next Page

Calling C Functions in Actions

This section describes the C functions that you can call directly in Stateflow action language. See the following topics:

Calling C Library Functions

You can call the following small subset of the C Math Library functions:

abs
acos
asin
atan
atan2
ceil
cos
cosh
exp
fabs
floor
fmod
labs
ldexp
log
log10
pow
rand
sin
sinh
sqrt
tan
tanh

Stateflow extends the abs function beyond that of its standard C counterpart with its own built in functionality. See Calling the abs Function.

You can call the above C Math Library functions without doing anything special as long as you are careful to call them with the right data types. In case of a type mismatch, Stateflow replaces the input argument with a cast of the original argument to the expected type. For example, if you call the sin function with an integer argument, Stateflow replaces the argument with a cast of the original argument to a floating-point number of type double.

If you call other C library functions not specified above, be sure to include the appropriate #include... directive in the Custom code included at the top of generated code field of the Target Options dialog. See the section Specifying Custom Code Options for Stateflow Targets.


Previous page  Using Special Symbols in Actions Calling the abs Function Next page

© 1994-2005 The MathWorks, Inc.