When using "Pause on Warning/Error," is there a way to avoid breaking into built-in functions?

29 visualizzazioni (ultimi 30 giorni)
For example, a bad set of data when calling "fit" breaks into a function called "curvefit.attention/Warning/throw":
Warning: Equation is badly conditioned. Remove repeated
data points or try centering and scaling.
> In curvefit.attention/Warning/throw (line 30)
In fit>iLinearFit (line 680)
In fit>iFit (line 391)
In fit (line 116)
In my_fit_function (line XX)
The message is useful, but having my workspace scope in "curvefit.attention/Warning/throw" is useless. It would be helpful to return the workspace scope to "my_fit_function" to see what data actually threw the warning/error. How can this be done? ~Thanks!
EDIT: I partly answered my own question. "Function Call Stack" in the IDE allows selecting the workspace scope. Still, it would be helpful to set the default behavior to break within user-defined scripts rather than in built-in functions, if possible.

Risposta accettata

Jan
Jan il 30 Giu 2021
Matlab cannot guess in which level you want to display the call stack. So either select it manually, or use try/catch/rethrow for a user-controlled error handling. Then Matlab stops in the level, you have inserted rethrow in.
  2 Commenti
Stefan Schuberth
Stefan Schuberth il 8 Giu 2022
Manual error handling is time consuming and the source code has to be modified. As Joel Lynch asked it should be possible to stop the call stack at the last user defined function throwing this error! This would be a much more powerful feature. Stopping in build-in functions is useless.
Paul Kujawa
Paul Kujawa il 22 Mag 2023
I agree wholeheartedly with Stefan. Not once have I ever paused execution with the intent of debugging at the level of whatever built-in function that is running at that time. At the very least don't dump me into the interrupt script of said function. Of course there's no reason why that ability shouldn't be retained as an option for those who do wish to debug built-in functions for whatever reason.

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Variables in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by