Filter löschen
Filter löschen

error handling

1 Ansicht (letzte 30 Tage)
oblivious
oblivious am 15 Mai 2012
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

Akzeptierte Antwort

Honglei Chen
Honglei Chen am 15 Mai 2012
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 Kommentar
oblivious
oblivious am 15 Mai 2012
thanks a lot

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by