This is very handy for when we want an idea of how a system works without having to actually observe the real system itself (saving time, and money!).
Using MATLAB, we can model the movement of cars to/from car rental places in Boston to Albany. We are told that 5% of the cars that start in Albany end up in Boston by the end of a week, while 3% of the cars in Boston end up in Albany by the end of a week. We want to see how the total number of cars change by the end of the week where the total number of cars in each city start at 150- and the totals at the end of successive weeks, or even a year!
We can model this behavior in MATLAB very easily and pretty quickly, versus waiting around to count the actual cars a year later.
car_update
At the top I made a note to define the starting values of a & b to allow the first calculation to run successfully. Running this program again and again gives us the new totals at the end of each week. We can make a program to run this a certain number of times by making another program that calls car_update and makes it run... say 52 times, thus modeling the totals after an entire year.
car_loop
We can see here that sometime after week 20, the rate of change of the car totals levels off... meaning Boston and Albany neither gain nor lose cars. We might say that it has reached equilibrium, since the number of cars leaving Boston to go to Albany exactly counterbalances the movement in the opposite direction, from Albany to Boston.
Typing this program didn't take so long, relative to the a year, which would be how long it'd take to actually observe these changes in real life. Thus, we see the benefits and ease of modeling the movement of cars mathematically, one useful aspect of MATLAB!
No comments:
Post a Comment