Is there any method to set breakpoints to all the lines of a .m file, except manually one by one?

Respuestas (4)

Jan
Jan el 2 de Ag. de 2011

1 voto

As Sean and Jiang I do not think that this is useful. But if you are sure that you need it:
i = 1;
while 1
try
dbstop(FuncName, sprintf('%d', i));
i = i + 1;
catch
break;
end
end

2 comentarios

math07 rizqi
math07 rizqi el 22 de Ag. de 2011
thanks, this answer really helped me.
Jan
Jan el 22 de Ag. de 2011
Is your problem solved?

Iniciar sesión para comentar.

Sean de Wolski
Sean de Wolski el 2 de Ag. de 2011

0 votos

Why not just set one on the first line and step through it?
doc dbstop
doc dbstep

2 comentarios

Horia
Horia el 2 de Ag. de 2011
A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
Sean de Wolski
Sean de Wolski el 2 de Ag. de 2011
How does it work any differently than having a break point on that line?

Iniciar sesión para comentar.

Fangjun Jiang
Fangjun Jiang el 2 de Ag. de 2011

0 votos

Why do you need that? You can debug by running code line by line (pressing F10).

2 comentarios

Horia
Horia el 2 de Ag. de 2011
A tedious solution.
Moreover, it doesn't work inside loops for errors due to something else than the loop itself.
Image Analyst
Image Analyst el 2 de Ag. de 2011
That doesn't make any sense. Typing F5 or F10 WILL work, even if you're stepping on a line that generates an error. How would an error get generated anyway, if not due to executing a statement in the loop that you are in? Doesn't make sense, unless you had some kind of parallel processing going and THAT process generated the error. Even that doesn't negate the fact that F5 and F10 will still work.

Iniciar sesión para comentar.

Walter Roberson
Walter Roberson el 2 de Ag. de 2011

0 votos

Yes, you can construct a script that would do this by issuing "dbstop" calls on your behalf. But like the others I do not see much point in it.

7 comentarios

Walter Roberson
Walter Roberson el 2 de Ag. de 2011
You say that "Moreover, it doesn't work inside loops for errors due to something else than the loop itself." Could you give an example of that, and an example of the behavior you observe in such a situation?
I do not see at the moment how it might be more "tedious" than continually having to press F5 or F10 to continue if you have a breakpoint at every line.
Horia
Horia el 2 de Ag. de 2011
We agree about pressing F5 or F10;
I you don't see the point, good luck with F5, F10...
Image Analyst
Image Analyst el 2 de Ag. de 2011
Horia's comment above does not make sense to me.
Walter Roberson
Walter Roberson el 2 de Ag. de 2011
I do not understand as yet what behavior you would like to see. Suppose breakpoints were turned on for every line: how would you work with the resulting function?
What is an example of a case where dbstep (or F10) does not work to your liking?
We are trying to understand the difference between what you want and what is already present. Already four experienced MATLAB programmers have not understood what you are trying to describe. That suggests that a longer explanation from you is more likely to lead to understanding than your telling us "If you don't see the point, good luck with F5, F10".
I have not encountered all possible code situations; it could be that what you are seeing something that (for example) only happens with "old style" OO programming in MATLAB in connection with (say) digitalio() callbacks. Impossible to say with the current information. _I_ haven't encountered problems with F5 / F10, but if you can provide reproducible code then I can explore the situation.
Horia
Horia el 2 de Ag. de 2011
As you (4) know,F12 (or a mouse click) selects only one line as a breakpoint.
Can all the lines of a .m file be selected at once?
Jan
Jan el 2 de Ag. de 2011
@Horia: Did my code what you want? If sets a break point in each line of the M-file, whose name is store in the variable FuncName. Does this differ from the requested behaviour, and if so, how?
Walter Roberson
Walter Roberson el 20 de Feb. de 2018
Editada: Walter Roberson el 20 de Feb. de 2018
If you were plotting a variable named values then
values(values<0) = nan;
MATLAB knows to skip plotting points with value nan.

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Centro de ayuda y File Exchange.

Preguntada:

el 2 de Ag. de 2011

Editada:

el 20 de Feb. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by