====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2012:math445:lab7 [2012/10/23 07:08] gibson |
gibson:teaching:fall-2012:math445:lab7 [2012/10/31 19:34] (current) gibson |
||
---|---|---|---|
Line 11: | Line 11: | ||
**2.** We are going to create our own code for the game of life and use a | **2.** We are going to create our own code for the game of life and use a | ||
different approach based that does not allow anything to live on | different approach based that does not allow anything to live on | ||
- | borders of the domain. We will let our board be 100x100 grid. Start a | + | borders of the domain. We will let our board be 50x50 grid. Start a |
new script file, and start it with the lines | new script file, and start it with the lines | ||
Line 42: | Line 42: | ||
''break'' do?). | ''break'' do?). | ||
- | **5.** Implement the code given in Chapter 12 that will update the ''L'' matrix | + | **5.** Implement the code given in the Moler text that will update the ''L'' matrix |
with boundary conditions that repeat the border cells. Later we will change the | with boundary conditions that repeat the border cells. Later we will change the | ||
boundary conditions to enforce zeros on all boundaries. | boundary conditions to enforce zeros on all boundaries. | ||
Line 64: | Line 64: | ||
your plots look better. If you use ''pause(0.5)'', Matlab will pause | your plots look better. If you use ''pause(0.5)'', Matlab will pause | ||
just half a second, instead of waiting for you to hit return. | just half a second, instead of waiting for you to hit return. | ||
+ | |||
+ | **Better idea:** put the ''figure(1)'' command outside the for-loop, in the | ||
+ | initialization portion of your code. | ||
**7.** You should now be able to run the code. If not debug it so that you | **7.** You should now be able to run the code. If not debug it so that you | ||
Line 88: | Line 91: | ||
might be easier) is plotted and then ''hold off'' after the last point is | might be easier) is plotted and then ''hold off'' after the last point is | ||
plotted. | plotted. | ||
+ | |||
+ | **Better idea**: Calculate four sparse matrices L1, L2, L3, L4, which are nonzero | ||
+ | wherever L is live and has 1, 2, 3, and 4 or more live neighbors, respectively. | ||
+ | Then plot all the nonzero entries of L1 with red, of L2 with blue, L3 with green, | ||
+ | and L4 with ''[0.5 0 0.5]''. | ||
**10.** Change the orange color in the above plots to purple. What is the | **10.** Change the orange color in the above plots to purple. What is the |