Exercise

Modify the code from the tutorial to make a plot showing the effect of the no. of time-steps n on the Euler's method solution. Use the following two values for n: 100 and 200. Make two calls to the Euler function for the two different time-steps.

Your modified plot of x vs. t should contain three curves:

  1. n=100 solution
  2. n=200 solution
  3. Analytical solution

Use a different line style and color for each curve. Modify the legend to suitably label the three curves. Change the axis limits as necessary. We suggest that you create a copy of the code from the tutorial and work with that.

Submit your modified code and plot.


Go to Comments

Go to all MATLAB Learning Modules

  • No labels