Filter löschen
Filter löschen

Debug mode in code with blocks(cells)

2 Ansichten (letzte 30 Tage)
Mikhail
Mikhail am 9 Okt. 2014
Bearbeitet: Per Pettersson am 27 Mai 2021
Hi, I often use blocks (cells?) (%%) in my programm. When I want to debug,say,third block, I insert breakpoint somewhere in this block. But I cannot evaluate (with ctrl+enter) until breakpoint. Is there a way to use breakpoints and not to evaluate all cells of the program each time?

Akzeptierte Antwort

Sean de Wolski
Sean de Wolski am 14 Okt. 2014
No. There is no way to do this. When you run a section, it essentially copies and pastes it to the command line to run, thus there is no defined line number/location/etc.
There are two workarounds. The first is to highlight the lines of code you want to run and right click run selection. Since the sections are running in the base workspace anyway, debug mode isn't going to let you see inside of another workspace anyway. You'll still be able to see the values just like in debug mode (I know this doesn't work for loops.
The other workaround is to put breakpoints inside of functions called in the section and then step through those functions.

Weitere Antworten (1)

Per Pettersson
Per Pettersson am 27 Mai 2021
Bearbeitet: Per Pettersson am 27 Mai 2021
Another workaround is to temporarily put the contents of the cell in a separate script file, test_cell.m and call this from you original script, this allows you to set break points.

Kategorien

Mehr zu Simulink Functions finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by