Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
17
Добавлен:
09.02.2015
Размер:
237.57 Кб
Скачать

If a function handle is bound to more than one built-in or

M-file, (that is, it represents a set of overloaded functions),

then the data type of the arguments x1 through xn, determines

which function is executed.

FEVAL is usually used inside functions which take function

handles or function strings as arguments. Examples include

FZERO and EZPLOT.

[y1,..,yn] = FEVAL(F,x1,...,xn) returns multiple output arguments.

Within methods that overload built-in functions, use BUILTIN(F,...)

to execute the original built-in function. Note that when using

BUILTIN, F must be a function name and not a function handle.

See also assignin, function_handle, functions, builtin, eval, evalin.

Overloaded methods:

Inline/feval

sfit/feval

fittype/feval

cfit/feval

evalExpr/feval

mbcinline/feval

Reference page in Help browser

doc feval

<evalin> - Evaluate expression in workspace.

EVALIN Evaluate expression in workspace.

EVALIN(WS,'expression') evaluates 'expression' in the context of

the workspace WS. WS can be 'caller' or 'base'. It is similar to EVAL

except that you can control which workspace the expression is

evaluated in.

[X,Y,Z,...] = EVALIN(WS,'expression') returns output arguments from

the expression.

See also eval, assignin.

Reference page in Help browser

doc evalin

<builtin> - Execute built-in function from overloaded method.

BUILTIN Execute built-in function from overloaded method.

BUILTIN is used in methods that overload built-in functions to execute

the original built-in function. If F is a string containing the name

of a built-in function then BUILTIN(F,x1,...,xn) evaluates that

function at the given arguments.

BUILTIN(...) is the same as FEVAL(...) except that it will call the

original built-in version of the function even if an overloaded one

exists (for this to work, you must never overload BUILTIN).

[y1,..,yn] = BUILTIN(F,x1,...,xn) returns multiple output arguments.

See also feval.

Reference page in Help browser

doc builtin

<assignin> - Assign variable in workspace.

ASSIGNIN Assign variable in workspace.

ASSIGNIN(WS,'name',V) assigns the variable 'name' in the

workspace WS the value V. WS can be one of 'caller' or 'base'.

See also evalin.

Reference page in Help browser

doc assignin

<run> - Run script.

RUN Run script.

Typically, you just type the name of a script at the prompt to

execute it. This works when the script is on your path. Use CD

or ADDPATH to make the script executable from the prompt.

RUN is a convenience function that runs scripts that are not

currently on the path.

RUN SCRIPTNAME runs the specified script. If SCRIPTNAME contains

the full pathname to the script, then RUN changes the current

directory to where the script lives, executes the script, and then

changes back to the original starting point. The script is run

within the caller's workspace.

See also cd, addpath.

Overloaded methods:

vdspdebug/run

eclipseide/run

ghsmulti/run

cgoptimrunner/run

cgoptim/run

designdev/run

xregoptmgr/run

mpc555_tgtaction/run

diab_tgtaction/run

codewarrior_tgtaction/run

ccsdebug/run

Reference page in Help browser

doc run

Scripts, functions, classes, and variables.

<script> - About MATLAB scripts and M-files.

SCRIPT About MATLAB scripts and M-files.

A SCRIPT file is an external file that contains a sequence

of MATLAB statements. By typing the filename, subsequent

MATLAB input is obtained from the file. SCRIPT files have

a filename extension of ".m" and are often called "M-files".

To make a SCRIPT file into a function, see FUNCTION.

See also type, echo.

Reference page in Help browser

doc script

<function> - Add new function.

FUNCTION Add new function.

New functions may be added to MATLAB's vocabulary if they

are expressed in terms of other existing functions. The

commands and functions that comprise the new function must

be put in a file whose name defines the name of the new

function, with a filename extension of '.m'. At the top of

the file must be a line that contains the syntax definition

for the new function. For example, the existence of a file

on disk called STAT.M with:

function [mean,stdev] = stat(x)

%STAT Interesting statistics.

n = length(x);

mean = sum(x) / n;

stdev = sqrt(sum((x - mean).^2)/n);

defines a new function called STAT that calculates the

mean and standard deviation of a vector. The variables

within the body of the function are all local variables.

See SCRIPT for procedures that work globally on the work-

space.

A subfunction that is visible to the other functions in the

same file is created by defining a new function with the FUNCTION

keyword after the body of the preceding function or subfunction.

For example, avg is a subfunction within the file STAT.M:

function [mean,stdev] = stat(x)

%STAT Interesting statistics.

n = length(x);

mean = avg(x,n);

stdev = sqrt(sum((x-avg(x,n)).^2)/n);

%-------------------------

function mean = avg(x,n)

%AVG subfunction

mean = sum(x)/n;

Subfunctions are not visible outside the file where they are defined.

You can terminate any function with an END statement but, in most

cases, this is optional. END statements are required only in M-files

that employ one or more nested functions. Within such an M-file,

every function (including primary, nested, private, and subfunctions)

must be terminated with an END statement. You can terminate any

function type with END, but doing so is not required unless the

M-file contains a nested function.

Normally functions return when the end of the function is reached.

A RETURN statement can be used to force an early return.

See also script, return, varargin, varargout, nargin, nargout,

Соседние файлы в папке Библиотеки Matlab