Page 505 - Applied Numerical Methods Using MATLAB
P. 505

494    MATLAB


























                         Figure I.2  The MATLAB file editor/debugger window.


                is (are) suspicious to be the source(s) of error, by clicking the pertinent
                statement line of the program with the left mouse button and pressing the
                F12 key or clicking ‘Set/Clear Breakpoint’ in the ‘Breakpoints’ pull-down
                menu of the Editor/Debugger window. Then, you will see a small red disk
                in front of every statement at which you set the breakpoint.
              2. Going to the MATLAB Command window, type in the name of the file
                containing the main program to try running the program. Then, go back to
                the Editor/Debugger window and you will see the cursor blinking just after
                a green arrow between the red disk and the first statement line at which
                you set the breakpoint.
              3. Determining which variable to look into, go to the Command window
                and type in the variable name(s) (just after the prompt ‘K>>’) or whatever
                statement you want to run for debugging.
              4. If you want to proceed to the next statement line in the program, go back
                to the Editor/Debugger window and press the F10 (single step) key or the
                F11 (step in) key to dig into a called routine. If you want to jump to the
                next breakpoint, press F5 or click ‘Run (Continue)’ in the Debug pull-down
                menu of the Editor/Debugger window. If you want to run the program until
                just before a statement, move the cursor to the line and click ‘Go Until
                Cursor’ in the Debug pull-down menu (see Fig. I.2).
              5. If you have figure out what is wrong, edit the pertinent part of the program,
                save the edited program in the Editor/Debugger window, and then go to the
                Command window, typing the name of the file containing the main program
                to try running the program for test. If the result seems to reflect that the
                program still has a bug, go back to step 1 and restart the whole procedure.
   500   501   502   503   504   505   506   507   508   509   510