error handling

5 ビュー (過去 30 日間)
oblivious
oblivious 2012 年 5 月 15 日
Hi,
I am working for a thesis where i need to check some code automatically. whenever an error is encountered while running an m-file i need to have the error message contained in a variable as a string. is it possible?
Also,is there any function so that MATLAB will return a preset value to a variable whenever error is encountered instead of throwing an error message?
-OBLI

採用された回答

Honglei Chen
Honglei Chen 2012 年 5 月 15 日
You could do something like this
try
...
catch me
errmsg = lasterror;
errstr = errmsg.message;
end
Alternatively you can also do
try
...
catch me
errstr = getReport(me,'basic');
end
  1 件のコメント
oblivious
oblivious 2012 年 5 月 15 日
thanks a lot

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by