error函数()

输出显示行和中止函数

error Display message and abort function.
error(MSGID, ERRMSG, V1, V2, …) displays a descriptive message
ERRMSG when the currently-running program encounters an error
condition. Depending on how the program code responds to the error,
MATLAB then either enters a catch block to handle the error condition,
or exits the program.

MSGID is a unique message identifier string that MATLAB attaches to the
error message to better identify the source of the error (see MESSAGE
IDENTIFIERS, below). 

ERRMSG is a character string that informs the user about the cause of
the error and can also suggest how to correct the faulty condition. 
The ERRMSG string may include predefined escape sequences, such as 
\n for newline, and conversion specifiers, such as %d for a decimal 
number.

Inputs V1, V2, etc. represent values or substrings that are to
replace conversion specifiers used in the ERRMSG string. The format 
is the same as that used with the SPRINTF function.

error(ERRMSG, V1, V2, ...) reports an error without including a 
message identifier in the error report.

error(ERRMSG) is the same as the above syntax, except that the ERRMSG
string contains no conversion specifiers, no escape sequences, and no
substitution value (V1, V2, ...) arguments.

error(MSGSTRUCT) reports the error using fields stored in the scalar
structure MSGSTRUCT. This structure can contain these fields:

    message    - Error message string
    identifier - See MESSAGE IDENTIFIERS, below
    stack      - Struct similar to the output of the DBSTACK function

If MSGSTRUCT is an empty structure, no action is taken and error
returns without exiting the program. If you do not specify the
stack, the error function determines it from the current file and line.

MESSAGE IDENTIFIERS
A message identifier is a string of the form

    [component:]component:mnemonic

that enables MATLAB to identify with a specific error. The string
consists of one or more COMPONENT fields followed by a single
MNEMONIC field. All fields are separated by colons. Here is an
example identifier that has 2 components and 1 mnemonic.

    'myToolbox:myFunction:fileNotFound'

The COMPONENT and MNEMONIC fields must begin with an 
upper or lowercase letter which is then followed by alphanumeric  
or underscore characters. 

The COMPONENT field specifies a broad category under which 
various errors can be generated. The MNEMONIC field is a string 
normally used as a tag related to the particular message.

From the command line, you can obtain the message identifier for an 
error that has been issued using the MException.last function. 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值