MATLAB Programming Fundamentals - MathWorks

(やまだぃちぅ) #1

Debug Code in the Live Editor


To diagnose problems in your live scripts or functions, debug your code in the Live Editor.
There are several ways to debug in the Live Editor:


  • Show output by removing semicolons.


  • Run to a specific line of code and pause using the button.




  • Step into functions and scripts while paused by using the button.



  • Add breakpoints to your file to enable pausing at specific lines when you run.


Show Output


A simple way to determine where a problem occurs in your live script or function is to
show output. To show the output for a line, remove the semi-colon from the end of that
line. The Live Editor displays each output with the line of code that creates it, making it
easy to determine where a problem occurs.

For example, suppose that you have a script called randomdata.mlx that plots a vector
of random data and draws a horizontal line on the plot at the mean.

19 Live Scripts and Functions

Free download pdf