Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Assignment 3


Write a script that
– Reads an input file that specifies the parameters:
a,b,c,d,x0,y0,tf
– Integrates the following system of equations given
the parameters read from the input file
– The system should be integrated from t=0 to t=tf.
– Plot the solution x(t) and y(t) in a single graph.
dx
=a x−b x y x(0)=x 0
dt
dy
=c x y−d y y (0)= y 0
dt
Assignment 3

Hints:
– If your curves are choppy, try reducing RelTol and AbsTol with odeset
– In matlab (newer versions, 2019+) there is the function readvars() that should
be usable to read the data:
https://www.mathworks.com/help/matlab/ref/readvars.html
– If you don’t have access to that function, you can look at suggestions like
here:
https://stackoverflow.com/questions/53146773/in-octave-how-to-load-variabl
e-and-value-from-txt-file
for a quick way to read the file

I suggest you separate the problem in 2 parts
– 1st just concentrate on reading the data file
– 2nd make the script integrate the data
– You can also consider the problem backwards: 1st just make a script that
does the integral and plots the results, then add in the functionality to read
the data from a file.

You might also like