>>addpath courses/242b/matlab/toolbox >> c1s10 Exercise number (1-14)? 12 >> M = 0.9700 0.0500 0.1000 0 0.9000 0.0500 0.0300 0.0500 0.8500 x0 = 304 48 98 >> % x0 is the initial car distribution or "population vector": Out of 450 cars at the initial time, 304 cars at the airport, 48 at the East office, 98 at the West office. M is the transition or migration matrix. For example the entry .03 indicates that 3% of the cars rented at the airport are returned to the West office at the end of one unit of time (i.e. one day), and the .90 indicates that 90% of the cars rented at the East office are returned to the East office. >> M*x0 ans = 307.0800 48.1000 94.8200 >> % This computes the population vector after one day: 307.08 cars are at the airport, etc. The fraction of cars at the airport shows the limitation of this mathematical model. >> M^7*x0 ans = 318.8649 46.4404 84.6947 >> %The population vector after 7 days, given by letting M act on x_0 seven times. >> M^100*x0 ans = 330.8806 39.7074 79.4121 >> M^1000*x0 ans = 330.8824 39.7059 79.4118 >> M^10000*x0 ans = 330.8824 39.7059 79.4118 >> % Notice that the car distribution has apparently stabilized: further iterations of the migration matrix don't affect the population vector. >> y0 = [200; 100; 150] y0 = 200 100 150 >> % We try a different initial population vector and see what happens to the long time car distribution >> M^10000*y0 ans = 330.8824 39.7059 79.4118 >> % We seem to get the same long time behavior. Let's try another initial distribution with all the cars at the West airport. >> z0 = [0;0;450] z0 = 0 0 450 >> M^10000*z0 ans = 330.8824 39.7059 79.4118 >> % Same long time behavior. Let's try a nonphysical initial car distribution. >> w0 = [-200, 100, 550] w0 = -200 100 550 >> M^10000*w0 ans = 330.8824 39.7059 79.4118 >> % We seem to get the same long time behavior no matter what initial population vector we pick (as long as the entries add up to 450). We'll see later on why this happens. >>quit