RE: make matrix animate
- To: mathgroup at smc.vnet.net
- Subject: [mg24916] RE: [mg24896] make matrix animate
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 20 Aug 2000 01:35:06 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Borut,
Yes.
For purposes of demonstration, I will generate a set of 15 random 5 x 5
matrices.
Needs["Graphics`Animation`"]
ran := Random[Integer, {0, 9}];
randommat := Table[ran, {5}, {5}]
Do[mat[i] = randommat, {i, 1, 15}]
This plot routine draws a square grid and places the matrix entries at the
center of each box.
plotmat[i_] := Module[{m = mat[i], ii, jj},
Show[Graphics[{(Line[{{0, #1}, {5, #1}}] & ) /@ Range[0, 5],
(Line[{{#1, 0}, {#1, 5}}] & ) /@ Range[0, 5],
Table[Text[m[[ii,jj]], {ii - 1/2, jj - 1/2}], {ii, 1, 5},
{jj, 1, 5}]}], AspectRatio -> Automatic]];
This animates the successive matrices.
Animate[plotmat[i], {i, 1, 15, 1}]
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]
FrontEndTokenExecute["SelectionAnimate"]
The last three statements automatically put the animation into action - a
trick I learned from Allan Hayes through MathGroup.
David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/
> -----Original Message-----
> From: Borut L. [mailto:JustMyName at email.si]
To: mathgroup at smc.vnet.net
>
> Helo,
>
> I made a function that has many matrices as output. It's in fact puzzle 15
> board, where in sequent matrices zero (blank space) moves
> left/right/up/down. Is there a way to make a graphical animation (like
> Do[Plot[...) with my output?
>
> Thanks a lot, Borut
>