| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → MATLAB |
| Contents | Index |
| Learn more about MATLAB |
msgstr
= lastwarn
[msgstr, msgid] = lastwarn
lastwarn('new_msgstr')
lastwarn('new_msgstr', 'new_msgid')
[msgstr, msgid] = lastwarn('new_msgstr',
'new_msgid')
msgstr = lastwarn returns the last warning message generated by the MATLAB software.
[msgstr, msgid] = lastwarn returns the last warning in msgstr and its message identifier in msgid. If the warning was not defined with an identifier, lastwarn returns an empty string for msgid. See Message Identifiers and Warning Control in the MATLAB Programming Fundamentals documentation for more information on the msgid argument and how to use it.
lastwarn('new_msgstr') sets the last warning message to a new string, new_msgstr, so that subsequent invocations of lastwarn return the new warning message string. You can also set the last warning to an empty string with lastwarn('').
lastwarn('new_msgstr', 'new_msgid') sets the last warning message and its identifier to new strings new_msgstr and new_msgid, respectively. Subsequent invocations of lastwarn return the new warning message and message identifier.
[msgstr, msgid] = lastwarn('new_msgstr', 'new_msgid') returns the last warning message and its identifier, also changing these values so that subsequent invocations of lastwarn return the message and identifier strings specified by new_msgstr and new_msgid, respectively.
lastwarn does not return warnings that are reported during the parsing of MATLAB commands. (Warning messages that include the failing file name and line number are parse-time warnings.)
Specify a message identifier and warning message string with warning:
warning('MATLAB:divideByZero', 'Divide by zero');Use lastwarn to determine the message identifier and error message string for the operation:
[warnmsg, msgid] = lastwarn warnmsg = Divide by zero msgid = MATLAB:divideByZero
warning, error, lasterr, lasterror
![]() | lasterror | lcm | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |