splitapply does not retain ME stack

31 Ansichten (letzte 30 Tage)
Vasco
Vasco am 15 Jan. 2026 um 11:02
Kommentiert: Walter Roberson vor 10 Minuten
When the function that splitapply throws an error, this line number of this error is not include in the output (matlab2024b)
Example:
T=table([1:3]');
G=findgroups(T);
splitapply(@fun, T, G);
function out = fun(varargin)
ERROR
end
This returns:
Error using splitapply>localsplitandapply (line 196)
Unable to apply the function 'fun' to the 1st group of data.
Error in splitapply (line 135)
varargout = localsplitandapply(fun,dataVars,gdiffed,sgnums,gdim,nargout);
Error in templateLoopOverAll (line 231)
splitapply(@fun, T, G);
Caused by:
Unrecognized function or variable 'ERROR'.
I was expeting that the line number that actually caused that error would be included:
Error in testfile>fun (line 5)
ERROR
Error in testfile (line 3)
fun()
Missing this information makes the debugging of fun very challenging.
How to retrieve this line number?
  1 Kommentar
Vasco
Vasco am 15 Jan. 2026 um 11:04
I think that this data is removed in splitapply.m line 243.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Matt J
Matt J am 15 Jan. 2026 um 13:24
Bearbeitet: Matt J am 15 Jan. 2026 um 13:32
Run with Pause on Errors.
Then the code will stop at the offending line:
  3 Kommentare
Vasco
Vasco vor etwa eine Stunde
Bearbeitet: Vasco vor etwa eine Stunde
This does not work on my installation, it stops at splitapply.m line 196
That seems not to work when I press: run this section (crtl-enter) -> it does not stop at al
Walter Roberson
Walter Roberson vor 10 Minuten
Try
dbstop if caught error

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Text Data Preparation finden Sie in Help Center und File Exchange

Produkte


Version

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by