Same line, same file, 2 different error messages - F9 vs F10

1 visualización (últimos 30 días)
Adam Langer
Adam Langer el 17 de Jun. de 2025
Editada: Benjamin Kraus el 17 de Jun. de 2025
My new repo was missing a file I was supposed to bring over from a previous repo. So, the line of code which tried to instantiate the class defined in that file threw an error. However it threw 2 different errors depending on how it was run. If the line was run executed regularly, it threw this exception (note that the constructor's first argument is of type char):
Undefined function '<my class name>' for input arguments of type 'char'.
It threw the same error if I put a breakpoint on that line and stepped over it (F10). But if, at that same breakpoint, I evaluated the line at the command prompt (F9) it threw this related but different exception:
Undefined function or variable '<my class name>'.
I have been using Matlab for a long time and I am stumped as to why the same line of code in the same debugging session can cause 2 different error messages by being run in different ways. Can anyone shed light on why this happens?
(UndocumentedMatlab - are you out there?)
  1 comentario
Benjamin Kraus
Benjamin Kraus el 17 de Jun. de 2025
Editada: Benjamin Kraus el 17 de Jun. de 2025
I suspect the difference is that one line is being run in the context of a function or class and the other is being run at the command line, but I tested a few things quickly and could only reproduce the second error message.
What is the error message ID in both cases? You can determine that by looking at the output from MException.last (or [~,errID] = lasterr). Knowing the error message ID would help me understand better what is happening.
If you can reproduce using a simple example and share that code, that would also be helpful.

Iniciar sesión para comentar.

Respuestas (0)

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by