P. 1
Incline Function

Incline Function

|Views: 0|Likes:
Published by Ajay Gupta

More info:

Published by: Ajay Gupta on Jun 13, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOCX, PDF, TXT or read online from Scribd
See more
See less

06/13/2012

pdf

text

original

INCLINE FUNCTION

Syntax
inline(expr) inline(expr,arg1,arg2,...) inline(expr,n)

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 two characters are found,

the one later in the alphabet is chosen.
inline(expr,arg1,arg2,...) constructs an inline function whose input arguments specified by the strings arg1, arg2,.... Multicharacter symbol names may be used. inline(expr,n) x, P1, P2, ... .

are

where n is a scalar, constructs an inline function whose input arguments are

Remarks
Three commands related to inline allow you to examine an inline function object and determine how it was created.
char(fun) converts formula(fun). argnames(fun)

the inline function into a character array. This is identical to

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
Example 1
This example creates a simple inline function to square a number.
g = inline('t^2') g = Inline function:

x) = sin(alpha*x) If inline does not return the desired function variables or if the function variables are in the wrong order. alpha and x: f = inline('sin(alpha*x)') f = Inline function: f(alpha.^2) argnames(f) ans = 'x' formula(f) ans = 3*sin(2*x. you can specify the desired variables explicitly with the inline argument list.g(t) = t^2 You can convert the result to a string using the char function.^2) Example 3 This call to inline defines the function f to be dependent on two variables. char(g) ans = t^2 Example 2 This example creates an inline function to represent the formula .alpha) = sin(alpha*x) Construct inline object Syntax .'x'. g = inline('sin(alpha*x)'. The resulting inline function can be evaluated with the argnames and formula functions.'alpha') g = Inline function: g(x.^2)') f = Inline function: f(x) = 3*sin(2*x. f = inline('3*sin(2*x.

the one closest to x is used. g = inline('t^2') g = Inline function: g(t) = t^2 You can convert the result to a string using the char function. Multicharacter symbol names may be used.) constructs an inline function whose input arguments specified by the strings arg1.. The result is a vectorized version of the inline function. constructs an inline function whose input arguments are Remarks Three commands related to inline allow you to examine an inline function object and determine how it was created. .n) Description inline(expr) constructs an inline function object from the MATLAB expression contained in the string expr..arg1.. x is used. that is not part of a word formed from several alphabetic characters.) inline(expr. Examples Example 1 This example creates a simple inline function to square a number. formula(fun) returns the formula for the inline object fun.arg2. inline(expr. This is identical to returns the names of the input arguments of the inline object fun as a cell array of strings. The input argument to the inline function is automatically determined by searching expr for an isolated lower case alphabetic character. If two characters are found.. . other than i or j..arg1.inline(expr) inline(expr. before any ^. .... arg2. char(fun) converts formula(fun).. A fourth command vectorize(fun) inserts a . are where n is a scalar. argnames(fun) the inline function into a character array. P2. inline(expr. If no such character exists..arg2.. P1. * or /' in the formula for fun.. the one later in the alphabet is chosen. If the character is not unique.n) x.

^2) Example 3 This call to inline defines the function f to be dependent on two variables.alpha) = sin(alpha*x) . alpha and x: f = inline('sin(alpha*x)') f = Inline function: f(alpha.x) = sin(alpha*x) If inline does not return the desired function variables or if the function variables are in the wrong order. The resulting inline function can be evaluated with the argnames and formula functions. f = inline('3*sin(2*x.^2) argnames(f) ans = 'x' formula(f) ans = 3*sin(2*x. you can specify the desired variables explicitly with the inline argument list.'alpha') g = Inline function: g(x.char(g) ans = t^2 Example 2 This example creates an inline function to represent the formula .'x'. g = inline('sin(alpha*x)'.^2)') f = Inline function: f(x) = 3*sin(2*x.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->