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

Value to use when the optional argument argname is not present in the

actual inputs to the function. The optional VALIDATOR input is the same

as for addRequired.

addParamValue(PARSEOBJ, PARAMNAME, DEFAULT, VALIDATOR) adds parameter

name/value argument PARAMNAME to the input scheme of object PARSEOBJ.

Parameter name/value pair arguments are parsed after required and

optional arguments. The PARAMNAME input is a single-quoted string that

specifies the parameter name and is the name of the parameter in the

results structure that is created when parsing. The DEFAULT input

specifies the value to use when the optional argument NAME is not

present in the actual inputs to the function. The optional VALIDATOR

input is the same as for ADDREQUIRED.

createCopy(PARSEOBJ) creates a copy of the inputParser. The

inputParser uses handle semantics, so a normal assignment does not

create a copy.

Properties:

Results - Structure array. The results of the last parse.

Each known parameter is represented by a field in the structure.

The name of the field is the name of the parameter and the value

stored in the field is the value of the input.

KeepUnmatched - Scalar logical. If TRUE, inputs that do not

match the input scheme are added to the UNMATCHED property. If

FALSE (default), MATLAB throws an error if an input that does not

match the scheme is found.

CaseSensitive - Scalar logical. If TRUE, parameters are matched

case sensitively. If FALSE (default), matching is case

insensitive.

StructExpand - Scalar logical. If TRUE (default), the PARSE

method accepts a structure as an input in place of param-value

pairs (INPUT1, INPUT2, etc.). If FALSE, a structure is treated as a

regular, single input.

FunctionName - Char array. The function name that is used in

error messages thrown by the validating functions.

Parameters - Cell array of strings. A list of the parameters

in the input parser. Each row is a string containing the full name

of a known parameter.

Unmatched - Structure array in the same format as the

Results. If KeepUnmatched is TRUE, this will contain the list of

inputs that did not match any parameters in the input scheme.

UsingDefaults - Cell array of strings. A list of the parameters

that were not set by the user and, consequently, are using their

default values.

Example:

p = inputParser;

p.addRequired('a');

p.addOptional('b',1);

p.addParamValue('c',2);

p.parse(10, 20, 'c', 30);

res = p.Results

Returns a structure:

res =

a: 10

b: 20

c: 30

See also validateattributes, validatestring.

Reference page in Help browser

doc inputParser

<ans> - Most recent answer.

ANS Most recent answer.

ANS is the variable created automatically when expressions

are not assigned to anything else. ANSwer.

Reference page in Help browser

doc ans

Message display.

<warning> - Display warning message.

WARNING Display warning message; disable or enable warning messages.

WARNING('MESSAGE') displays the warning message MESSAGE, unless it has been

disabled (see the special identifier 'all' in "Controlling Warning Message

Display" below). When MESSAGE is the only input to WARNING, WARNING displays

it literally, without performing any substitutions (see below) on the

characters in MESSAGE.

WARNING('MESSAGE', A, B, ...) displays the formatted warning message

MESSAGE. The string MESSAGE may contain escape sequences (such as \t or \n)

as well as the C language conversion specifiers (e.g., %s or %d) that are

supported by the SPRINTF function. WARNING makes substitutions for the

escape sequences and conversion specifiers in the same way that SPRINTF

does. Additional arguments A, B, ... provide the values that correspond to

the format specifiers and are only required if conversion specifiers appear

in MESSAGE. Type HELP SPRINTF for more information on escape sequences and

format specifiers. WARNING performs these substitutions on MESSAGE in all

cases where more than one input is passed to WARNING.

WARNING('MSGID', 'MESSAGE', A, B, ...) displays the formatted warning

message MESSAGE as in the paragraph above, and tags the warning with the

message identifier MSGID. The identifier can be used to enable or disable

display of the identified warning (See "Controlling Warning Message Display"

below). A message identifier is a string of the form

<component>[:<component>]:<mnemonic>, where <component> and <mnemonic> are

alphanumeric strings (for example, 'MATLAB:singularMatrix').

Controlling Warning Message Display

-----------------------------------

WARNING('OFF', 'MSGID') and WARNING('ON', 'MSGID') disable and enable the

display of any warning tagged with message identifier MSGID. (Use LASTWARN

to determine the identifier of a warning, or use the WARNING VERBOSE feature

described below.) WARNING is not case sensitive when matching message

identifiers.

S = WARNING('OFF', 'MSGID') and S = WARNING('ON', 'MSGID') additionally

return the previous warning state of any warning tagged with message

identifier MSGID. This state information is returned in a structure S with

fields 'identifier' and 'state'.

WARNING('QUERY', 'MSGID') displays the state ('on' or 'off') for warnings

with message identifier MSGID. S = WARNING('QUERY', 'MSGID') returns the

state in a structure S with fields 'identifier' and 'state'.

In the three cases above, MSGID can also be 'all', in which case all

warnings (including untagged ones) are disabled, enabled, or queried, as

well as 'last', in which case the last displayed warning is disabled,

enabled, or queried.

WARNING ON BACKTRACE and WARNING OFF BACKTRACE control the display of the

file and line number that produced a warning when the warning is displayed.

WARNING ON VERBOSE and WARNING OFF VERBOSE control the displaying of an

extra line of helpful text containing the warning identifier when a warning

is displayed.

S = WARNING('QUERY', ARG) where ARG is either 'BACKTRACE' or 'VERBOSE'

returns a structure S with fields 'identifier' containing ARG and 'state'

containing the current state of ARG.

WARNING(S) where S is a structure with fields 'identifier' and 'state' is

equivalent to

for k = 1:length(S), warning(S(k).state, S(k).identifier); end

In other words, WARNING accepts as an input the same structure it returns as

an output. This restores the states of warnings to their previous values.

See also sprintf, lastwarn, disp, error, errordlg, warndlg.

Reference page in Help browser

doc warning

<lasterr> - Last error message.

LASTERR Last error message.

LASTERR is maintained for backward compatibility.

This function depends on global state, and its programmatic use is not

encouraged. The newer syntax,

try

execute_code;

catch exception

do_cleanup;

throw(exception);

end

should be used instead, where possible. At the command line,

MException.last contains all of the information in LASTERR.

LASTMSG = LASTERR returns a string containing the most recent error

message issued by MATLAB.

[LASTMSG, LASTID] = LASTERR returns two strings, the first containing

the most recent error message issued by MATLAB, the second containing

the message identifier string corresponding to it. (See HELP ERROR for

more information on message identifiers).

LASTERR('') resets the LASTERR function so that it returns an empty

string matrix for both LASTMSG and LASTID until the next error is

encountered.

LASTERR('MSG', 'MSGID') sets the last error message to MSG and the last

error message identifier to MSGID. MSGID must be a valid message

identifier (or an empty string).

See also MException, MException/last, lasterror, error, lastwarn, try,

catch.

Reference page in Help browser

doc lasterr

<lasterror> - Last error message and related information.

LASTERROR Last error message and related information.

LASTERROR returns a structure containing the last error message issued

by MATLAB as well as other last error-related information. The

LASTERROR structure is guaranteed to contain at least the following

fields:

message : the text of the error message

identifier : the message identifier of the error message

stack : the location of the error, in the same format as the

output of dbstack.

LASTERROR(ERR) sets the LASTERROR function to return the information

stored in ERR as the last error. The only restriction on ERR is that it

must be a scalar structure. Fields in ERR whose names appear in the

list above are used as is, while suitable defaults are used for missing

fields (for example, if ERR doesn't have an 'identifier' field, then

the empty string is used instead, and, if a stack field is not present,

the stack is set to be a 0-by-1 structure with the fields: file, name,

and line.)

LASTERROR('reset') sets last error information to the default state.

message : ''

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