% This is will demonstrate the wabbit population example previously shown % in excel %format will control the format of all output format long %First we define b - our birth fraction b = 0.5 %Next define dt - our time step dt = 1 %the vector r will be initialized so that the first entry is the initial %number of rabbits, in this case 2 and we will give a size appropriate to %our for loop r_init = [2 zeros(1,24)]' %here we call the function grow and supply the current values of b and dt %to obtain the change in the wabbit population r = grow(r_init,b,dt) %now that we have the vector containing our the values for our wabbit %population over time, we want to see the data represented in graph form so %we will plot it plot(r) %so we will know what it is, we'll give the plot a title title('Wabbits') xlabel('Time') %ylabel('W') %if we wanted to have multiple lines plotted on the same graph, that is, if %we wanted to compare the results for different birth fractions, we can use %the hold functionality of matlab hold on %the same process follows with a b of 0.75 b = 0.75 r2 = grow(r_init,b,dt) plot(r2) hold on