>> help sys_runge_kutta_2 the program takes the intial data x_0 and y_0 at the initial time t_0 and computes up to time t_final using timesteps of size dt. It creates three vectors, t, x and y, which you can then plot against each other plot(x,y), hold on, plot(x(1),y(1),'o') [t,x,y] = sys_runge_kutta_2(x_0,y_0,t_0,t_final,dt) find the solution x(t), y(t): >> [t,x,y] = sys_runge_kutta_2(0,1,0,10,.01); plot x versus t in figure 1. The command "figure(1)" pops the graph out so you can see it. >> plot(t,x), figure(1) plot y versus t in figure 1. The command "figure(1)" pops the graph out so you can see it. >> plot(t,y), figure(1) plot x versus y in figure 1. The command "figure(1)" pops the graph out so you can see it. >> plot(x,y), figure(1) check that the initial data is correct: x_0 = 0, y_0 = 1: >> x(1) ans = 0 >> y(1) ans = 1 I want to plot the initial data on the figure. If I don't type "hold on" then the present figure will be erased. If I type "hold on" then the present figure will be saved and new stuff will be written on top of it. >> hold on; plot(x(1),y(1),'o'); figure(1) >> [t,x,y] = sys_runge_kutta_2(0,2,0,10,.01); Note: since I haven't typed "hold off" yet, figure(1) is still in the "keep writing" mode. So the following plots x versus y with the new initial data on the same plot as x versus y with the previous initial data. >> plot(x,y), figure(1) I now want to look at x versus t. I need to tell matlab that I'm going to plot it in a different window, since the last "figure" command matlab saw was "figure(1)". So matlab's going to put everything in figure 1 until told otherwise. I type "figure(2)" to inform matlab to put everything in figure(2) until told otherwise. I then plot and then type "figure(2)" again to pull the figure forward. >> figure(2); plot(t,x); figure(2) Compute with the same initial data, but I'd gone into F_sys.m and introduced friction. >> [t,x,y] = sys_runge_kutta_2(0,2,0,100,.1); plot x versus t in figure 2. >> plot(t,x); figure(2) plot x versus y back in figure 1. >> figure(1); plot(x,y), plot(x(1),y(1),'o'); figure(1) now I've decided that I didn't want to put that curve in. So I write over it with white (since the background's white). If the background were black, I'd use "k-" and "ko" below. >> plot(x,y,'w-'), plot(x(1),y(1),'wo'); figure(1) We then did a bunch of stuff with the Lottke-Volterra system. Skipping to the chase, we finally had a figure we wanted to print out. So first we plot the data: >> figure(2); plot(t,x); hold on; plot(t,y,'--'); hold off; figure(2); Set the axes in a way that we like (time goes from 0 to 5, the vertical axis goes from 0 to 400). >> axis([0,5,0,400]); figure(2) Label the x-axis >> xlabel('time'); Put in a title >> title('Deer and wolves. solid: deer, dashed: wolves'); Put some text in. Note that gtext automatically pops the figure forward. You place the left-hand of the text and then make it stick by clicking the mouse button. NOTE: there's no way to erase the text once it's placed, so be careful! Use short sentence fragments until you're used to gtext. >> gtext('the wolves are bad hunters and eaters'); >> gtext('so the deer can grow quite a bit'); >> gtext('before the wolves can catch up and kill them'); Print the figure as a *.ps file which you can print w/ ghostview. Or mail to me to print. Or you can print directly from the figure window by popping the figure forward and using the "file" pull-down menu. >> print -dps deers_win.ps >> diary off