Table Of Contents

Debugging MATLAB® Functions and Scripts

    Last Modified: August 24, 2018

    You can debug MATLAB functions and scripts when you use an Interface for MATLAB to call them in your G dataflow application.

    Complete the following steps to debug a function or script.


    You must follow these steps in the MATLAB Command Window that launches when you execute the G dataflow application. Otherwise, you cannot debug the function or script.

    1. In the automatically launched MATLAB Command Window, enter the cd path command to call the directory where the MATLAB function or script is located. For example, if the file is in the d:\math directory, enter the following command: cd d:\math.

      If the function or script is on the MATLAB search path, skip this step.

    2. Use the edit filename command to open the function or script for edit in the MATLAB Editor. For example, to edit the test.m file, enter the following command: edit test.m.
    3. In the MATLAB Editor, set a breakpoint on the line of code where you think the problem could be.
    4. Run your G dataflow application again. The execution of the MATLAB function or script pauses at the specific line where you set the breakpoint.
    5. While the function or script is paused, you can view the value of each argument in the MATLAB Editor.
    6. Click Continue in the MATLAB Editor. The G dataflow application finishes executing the remaining code.
    7. Change the values of arguments or modify the script or function to produce expected results by using standard MATLAB functionality.

    Recently Viewed Topics