MATLAB Function Reference Previous page   Next Page
intwarning

Control state of integer warnings

Syntax

Description

MATLAB has four types of integer warnings. The intwarning function enables, disables, or returns information on these warnings:

intwarning('action') sets or displays the state of integer warnings in MATLAB according to the string, action. There are three possible actions, as shown here. The default state is 'off'.

Action
Description
off
Disable the display of integer warnings
on
Enable the display of integer warnings
query
Display the state of all integer warnings

s = intwarning('action') sets the state of integer warnings in MATLAB according to the string action, and then returns the previous state in a 4-by-1 structure array, s. The return structure array has two fields: identifier and state.

intwarning(s) sets the state of integer warnings in MATLAB according to the identifier and state fields in structure array s.

sOld = intwarning(sNew) sets the state of integer warnings in MATLAB according to sNew, and then returns the previous state in sOld.

Remarks

Examples

General Usage

Examples of the four types of integer warnings are shown here:

Attempt to convert NaN (Not a Number) to an unsigned integer:

Attempt to convert a floating point number to an unsigned integer:

Attempt to convert a large unsigned integer to a signed integer, where the operation overflows:

Attempt an integer arithmetic operation that overflows:

Example 1

Check the initial state of integer warnings:

Convert a floating point value to an 8-bit unsigned integer. MATLAB does the conversion, but that requires rounding the resulting value. Because all integer warnings have been disabled, no warning is displayed:

Store this state in structure array iwState:

Change the state of the ConvertNonIntVal warning to 'on' by first setting the state to 'on' in the iwState structure array, and then loading iwState back into the internal integer warning settings for your MATLAB session:

Verify that the state of ConvertNonIntVal has changed:

Now repeat the conversion from floating point to integer. This time MATLAB displays the warning:

See Also

warning, lastwarn


Previous page  intmin inv Next page

© 1994-2005 The MathWorks, Inc.