splitapply does not retain ME stack

39 visualizaciones (últimos 30 días)
Vasco
Vasco el 15 de En. de 2026 a las 11:02
Editada: Matt J hace alrededor de 6 horas
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 comentario
Vasco
Vasco el 15 de En. de 2026 a las 11:04
I think that this data is removed in splitapply.m line 243.

Iniciar sesión para comentar.

Respuestas (1)

Matt J
Matt J el 15 de En. de 2026 a las 13:24
Editada: Matt J el 15 de En. de 2026 a las 13:32
Run with Pause on Errors.
Then the code will stop at the offending line:
  4 comentarios
Walter Roberson
Walter Roberson hace alrededor de 5 horas
Try
dbstop if caught error
Matt J
Matt J hace alrededor de 3 horas
Editada: Matt J hace alrededor de 3 horas
dbstop if error should be sufficient in R2024b when the script is run in full. My demo above used that.
The other observations are intended behavior.

Iniciar sesión para comentar.

Categorías

Más información sobre Text Data Preparation en Help Center y File Exchange.

Productos


Versión

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by