Know if my script gets an error

조회 수: 4 (최근 30일)
Javier Naranjo
Javier Naranjo 2017년 10월 3일
댓글: Jan 2017년 10월 3일
Hello everybody,
I am running a Matlab script in my Linux console and when it gets an error, the code continues its execution. Is there a way to stop the execution if an error occurs and not generate the outputs.
Thanks in advance,
Javi
  댓글 수: 2
Geoff Hayes
Geoff Hayes 2017년 10월 3일
Javier - what type of error are you seeing? Typically the script will end if an error is encountered. Please provide more details.
Javier Naranjo
Javier Naranjo 2017년 10월 3일
Optimization problems for instance.
Anyway, I have seen error while debugging and it always continues the execution. It never stops.
Thanks in advance for your quick answer,
Javi

댓글을 달려면 로그인하십시오.

채택된 답변

Jan
Jan 2017년 10월 3일
What does "running a Matlab script in a Linux console" exactly mean? You can run Matlab scripts inside Matlab only. Then the command error stops the execution, except if you prevent the script from doing so by a try/catch block. If this happens, the solution is easy: Do not let the code proceed after a severe problem, but stop if by an error.
Without seeing the relevant part of the code or understanding where you run what, I cannot post a more specific answer.
  댓글 수: 2
Javier Naranjo
Javier Naranjo 2017년 10월 3일
편집: Javier Naranjo 2017년 10월 3일
That means executing matlab ./matlab < myfunction.m. When an error occurrs like not variable found the function continues. Thats is what I mean.
Thanks
Jan
Jan 2017년 10월 3일
If an error occurs, the function of script stops. This is the nature of errors. I cannot reconsider, what you mean by "it never stops". At least without seeing any detail, it will be impossible to solve the problem.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by