Skip to main content
Werner_E
25-Diamond I
March 22, 2013
Solved

How to keep random values during animation?

  • March 22, 2013
  • 9 replies
  • 2659 views

I would like to create an animation with Mathcad 15 which utilizes random numbers. As the sheet is recalculated for every animation step I have to find a means to keep some values randomly generated in on step of the animation to be used in the next one.

I have found two ways to accomplish that which both have their disadvantges and therefore would like to know if anybody can think of a third way.

(1) I could use Seed(..) to generate the same set of random numbers for each step

(2) I could write the values to keep in a file and read them in for each animation step

As the values are large matrices which take some time to calculate I would prefer those values to be kept in the sheet / in memory without the need to regenerate all of them (1) or to work with file I/O (2).

The only additional method I could think of is using scripted components in some way, but I'm not versed well enough to do so.

Any ideas welcome.

Werner

Best answer by AlanStevens

Perhaps I misunderstand what you are after, but cannot you simply generate a large matrix of random values near the beginning of the worksheet, then simply index into that matrix during each animation step?

A trivial example is attached.

Alan

9 replies

19-Tanzanite
March 23, 2013

Perhaps I misunderstand what you are after, but cannot you simply generate a large matrix of random values near the beginning of the worksheet, then simply index into that matrix during each animation step?

A trivial example is attached.

Alan

Werner_E
Werner_E25-Diamond IAuthor
25-Diamond I
March 23, 2013

Thanks for your input, Alan!

Unfortunately its not that easy. Each animiation step would consist of calculating 2 big matrices which depend on the two previous ones with random elements which can't be precaclculated (edited: probably they can) that easy as they somewhat (range,..) depend on some matrix elements of the previous step.

I thought of precalculating the whole 600 step animation but discarded that idea as it would not have been possible in Mathcad to keep all 1200 matrices.

Upon reading your post and thinking about it again it dawned to me, that I can precalculate the whole animation as I would only have to keep the animation data which are derived from those 2 matrices and which a rather small - no problem to kepp 1200 or more of them.

I am pretty sure that it would be possible as well to follow your proposal of precalculating only a set (two in my case, as I would need uniform an normal distribute ones) and rewrite the constiuction of my two matrices. But I think this would not be necessary anymore.

Thanks again for pointing me in the right direction.

Werner

19-Tanzanite
March 24, 2013

The scripted component approach has come up before, although in a different context. The desire then was to allow the symbolic processor to use random numbers, but I think the component in the attached worksheet would also do what you want. I haven't tried it though, so I can't be sure. The symbolic processor can't "see through" the component, but perhaps the numeric processor can.

Werner_E
Werner_E25-Diamond IAuthor
25-Diamond I
March 24, 2013

Thanks, thats an Interesting sheet anyway. I will give it a try but in my case I think I will stick to the precalculation of the animation data.