MATLAB Function Reference
  Go to function:
    Search    Help Desk 
inline    Examples

Construct an inline object

Syntax

Description

inline(expr) constructs an inline function object from the MATLAB expression contained in the string expr. The input argument to the inline function is automatically determined by searching expr for an isolated lower case alphabetic character, other than i or j, that is not part of a word formed from several alphabetic characters. If no such character exists, x is used. If the character is not unique, the one closest to x is used. If there is a tie, the one later in the alphabet is chosen.
  inline(expr,arg1,arg2, ...) constructs an inline function whose input arguments are specified by the strings arg1, arg2,.... Multicharacter symbol names may be used.

inline(expr,n), where n is a scalar, constructs an inline function whose input arguments are x, P1, P2, ...

Remarks

Three commands related to inline allow you to examine an inline function object and determine how it was created.

char(fun) converts the inline function into a character array. This is identical to formula(fun).

argnames(fun) returns the names of the input arguments of the inline object fun as a cell array of strings.

formula(fun) returns the formula for the inline object fun.

A fourth command vectorize(fun) inserts a . before any ^, * or /' in the formula for fun. The result is a vectorized version of the inline function.

Examples

Create a simple inline function to square a number:

Create an inline function to compute the formula :



[ Previous | Help Desk | Next ]