Skip to main content

CH925 - MatLab Code

A number of numerical methods used for root finding, and solving ordinary differential equations (ODEs) were covered in this module. I found it was useful to try writing out each method to practice working with MatLab. I have uploaded each piece so that others might find the code useful to cannibalise for workshop questions etc. I've tried commenting the code for the most part so that it's easy to follow.

Introduction to MatLab:

This is a basic introduction to some of the features of MatLab which may be a useful starting point if you have very little experience with it. You can delete the semicolon after statements to view their outputs (this was for the format of the teaching session given to an introductory class).

Introduction: (Text file)

Root Finding Methods:

  1. Bisection Method: (Text file)
  2. Fixed Point Iteration: (Text file)
  3. Newton-Raphson Method: (Text file)
  4. Secant Method (Newton-Raphson variant): (Text file)
  5. Halley's Method (Newton-Raphson variant): (Text file)

Solving ODEs:

  1. Euler's Method: (Text file)
  2. Improved Euler's Method: (Text file)
  3. Runge-Kutta Method: (Text file)
  4. Ode45 example, SEIR model: (Text file)

Example of creating movies using MatLab:

For the code used to create the standing waves movie, it is found here.(Text file)