Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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
Solved! Go to Solution.
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
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
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
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.
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.
I tried to create a tiny animation - a "growing" vector consisting of random numbers - using that component, but have no idea how I would do.
The idea was to create something like the attached (the elements of the vector V are random numbers). The animation was done by picking the appropriate elelemnts from a precalculated array, though.
I guess I misunderstood what you were trying to do. Now I do understand, I can't figure out how to do it either, with or without the component. The only solution seems to be Alan's suggestion.
Richard Jackson wrote:
I guess I misunderstood what you were trying to do. Now I do understand, I can't figure out how to do it either, with or without the component. The only solution seems to be Alan's suggestion.
Thats bad. I was hoping it would be possible to save a matrix somewhere in a component or via a component in the metadata of the sheet at the end of one animation step and retrieve it from there at the beginning of the next step.
I have just learned that Mathcad wont let me create much more than two vectors with 10^7 random numbers each (with 10^8 I get the "Not enough memory for this operation" error on my machine). So I will have to stick with one of my two methods from my first posting here. As using Seed() and recalculating the whole sequence up to the current point in the animation would be more time consuming than saving the current state to a file and retrieving it in the next step, I will have to resort to that latter method.
This is kind of crude and could use some refinements, but it works.
Great!! Thanks a lot - seems to be just what I was looking for.