the VarsList to gather data from
Optional
opt_capacity: numbernumber of data samples to store, default is 100000
number formatting function
number formatting function
separator between numbers
Private
varSet of index numbers into VarsList, specifies which variables to memorize.
Returns the HistoryList of data points.
Returns string form of the data points. One line for each sample, using the number formatting function and text separator specified by the properties numberFormat and separator.
Optional
opt_localized: booleantrue
means print the localized versions of the
variable names; false
means print the language independent variable names;
default is true
Sets the array of variable index numbers specifying which variables to memorize. This calls reset which erases all stored data.
array of variable index numbers specifying which variables to memorize
Returns a minimal string representation of this object, usually giving just identity information like the class name and name of the object.
For an object whose main purpose is to represent another Printable object, it is
recommended to include the result of calling toStringShort
on that other object.
For example, calling toStringShort()
on a DisplayShape might return something like
this:
DisplayShape{polygon:Polygon{'chain3'}}
a minimal string representation of this object.
Generated using TypeDoc
Collects data from a VarsList and provides ways to print or access that data. The data is stored in a HistoryList with each entry being an array of numbers (a 'data sample') representing the value of the variables at a point in time.
The data is stored whenever memorize is called. As a Memorizable the VarsHistory can be connected to a MemoList such as SimRunner. In most myPhysicsLab apps the following commands entered in Terminal will set this up:
To memorize the starting initial conditions, call the memorize function once before starting the simulation.
Run the simulation as long as desired. After the simulation run is completed, print the data:
The resulting text can then be copied from the Terminal text box, saved as a text document and imported into a spreadsheet program or graphed with a Python script.
The default separator between numbers is the tab character. To instead use comma separated values:
To change which variables are sampled or the order of the variables within each sample use setVariables. For example:
Note that
setVariables
erases all stored data, so you would need to callmemorize
afterwards to store initial conditions.The default format for printing numbers gives 5 decimal places, but if the number is too small then switches to exponential format. Use setNumberFormat to change the formatting function. For example:
That example uses an arrow function but you can provide any function that takes one numeric argument and returns a string.
To process the data using Javascript use the
toArray
method