matlab mxassert函数语法

发表matlab mxassert函数相关文章
一句话说明: Check assertion value for debugging purposes

mxAssert (C)

Check assertion value for debugging purposes

C Syntax

#include "matrix.h"
void mxAssert(int expr, char *error_message);



Value of assertion


Description of why assertion failed


Like the ANSI® C assert macro, mxAssert checks the value of an assertion, and continues execution only if the assertion holds. If expr evaluates to logical 1 (true), mxAssert does nothing. If expr evaluates to logical 0 (false), mxAssert terminates the MEX-file and prints an error to the MATLAB® command window. The error contains the failed assertion's expression, the file name and line number where the failed assertion occurred, and the error_message string. The error_message string allows you to specify a better description of why the assertion failed. Use an empty string if you do not want a description to follow the failed assertion message.

The mex script turns off these assertions when building optimized MEX-functions, so use this for debugging purposes only. Build the MEX-file using the syntax mex -g filename in order to use mxAssert.

Assertions are a way of maintaining internal consistency of logic. Use them to keep yourself from misusing your own code and to prevent logical errors from propagating before they are caught; do not use assertions to prevent users of your code from misusing it.

Assertions can be taken out of your code by the C preprocessor. You can use these checks during development and then remove them when the code works properly, letting you use them for troubleshooting during development without slowing down the final product.

See Also

mxAssertS, mexErrMsgIdAndTxt


与matlab mxassert用法相关的文章

友情链接It题库(| 版权归yishouce.com所有| 友链等可联系|粤ICP备16001685号-1