Exercises

Write the programs in Matlab.

  1. Write a new program or open an existing program. Introduce some errors, by mispelling commands or values. Use the debugging operations to see what happens when the debugger reaches the errors that you introduced.

    Use Ctrl-C if you need to cancel execution of your program. You can then restart the program to see if your fixes work.

  2. Write a new program or open an existing program that contains nested if statements and use the debugger to trace the execution for different values. Be sure to trace both paths of execution.

    Try changing the values of variables while in the debugger to see what happens.

  3. Set a breakpoint in the ashlee function of the code we provided for Team Lab 8 Convergence. Then run the ashlee function from the command window to approximate the area under the curve. Step through the execution of the ashlee, oj, and jessica to see how Simpson's Method is implemented in Matlab.

    We will present iterative statements (loops) in a later lesson, but by stepping through them one line at a time now, you can see how the variables change as lines are executed and exactly which commands are repeated in a loop.