try/catch 構文で、エラーが発生した行番号を取得できますか?

21 views (last 30 days)
MathWorks Support Team
MathWorks Support Team on 14 Nov 2019
try/catch ステートメントを使っています。エラーが発生した行番号を取得する方法を教えてください。

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Nov 2019
try/catchステートメントで、エラーが発生した行番号を取得するには、MException オブジェクトにアクセスします。
例:
try
surf
catch ME
error_line = ME.stack(end).line % 行番号
end
以下の URLより関連ドキュメンテーションをご覧いただけます。
・MATLAB: 例外への応答

More Answers (0)

Categories

Find more on エラー処理 in Help Center and File Exchange

Tags

No tags entered yet.

Products


Release

R2013a

Community Treasure Hunt

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

Start Hunting!