Data Table Component
Insert a one- or two-dimensional data table in a Standard Maple worksheet or document.
Using the Data Table
Component Palette Image
Data Table Example
Data Tables in Maple
The data table component performs an action or a series of actions to communicate with other embedded components when the data table is updated, although assigning an action to a component is not required.
The data structure used to store the data is an rtable.
You can insert this embedded component from the Components palette.
There are three ways to populate the data table with entries:
By referencing the name of an existing Matrix, Array, Vector, or other rtable
By filling in the initial values interactively
By importing the initial values from a file
Associating the data table with an existing Matrix
If you have already defined a Matrix, Array, Vector, or other rtable in your document, you can associate the data table with that rtable. The rtable must be assigned to a name.
To associate the data table with an existing Matrix:
Insert the Data Table Component from the Components palette.
Select Use existing Matrix.
Select the name of the rtable from the drop-down list.
Filling in data table values interactively
To fill the initial values interactively:
Insert a Data Table Component.
Select Create new Matrix and specify a variable name for the rtable.
Specify the total number of rows and columns of the rtable.
Set other properties, as desired, and then click OK. The component is inserted in the document with initial values of 0.
Double-click each table cell to edit the value.
Importing data table values from a file
To import the initial values from a file:
Insert a Data Table Component.
Select Import Matrix and specify a variable name for the rtable.
The Data Import Assistant dialog opens. This dialog is an interactive interface that allows you to import data into Maple.
In the Data Import Assistant dialog, browse to the location of the file you want to import data from, select the file, and then click Next.
Note: The following file formats are supported: Excel®, MATLAB®, Image, Audio, Matrix Market, Comma Separated Values, and Delimited
Set the appropriate import options for your data and, optionally, preview your data within the Data Import Assistant dialog.
Click Done to close the Data Import Assistant and import the data into the Data Table Component.
To perform an action when the data table is updated, click the data table, and then, from the Data Table context panel, select Edit Content Changed Code to open the Code Editor dialog for the data table. Enter the commands you want to perform in the Code Editor dialog. For more information, see the Data Table Example on this page.
The data table component is customized by setting options in the Data Table context panel. To display the Data Table context panel, click the data table component. Actions are associated with components using routines in the DocumentTools package.
The column widths can be set interactively by dragging the column boundaries or programmatically as described in the DataTable Properties section below.
The Component Name property is used to reference the data table when using the routines from the DocumentTools package.
The data table is always associated with a Matrix (or Array). When you modify that Matrix, the data table is updated. See Example 2.
To force an update of the data table, use DocumentTools[SetProperty]("DataTable0",update), where DataTable0 is the name of your data table.
The following table describes the control and use of the data table component options.
An x in the Get column indicates that the option can be read, that is, retrieved by using the DocumentTools[GetProperty] tool.
An x in the Set column indicates that the option can be written, that is, set by using the DocumentTools[SetProperty] tool.
true or false
list of strings
list of integers
Specifies if the names for the columns of the table are visible.
Specify names for the columns of the table.
Specify widths (in pixels) for the columns of the table. The column widths have to specified as a list. For example:
SetProperty("DataTable0",columnWidths, [20, 20, 20, 20]);
Indicates whether the table cells are editable. By default, the value is true.
Indicates whether the data table component is enabled. If enabled is set to false, it is not possible to interactively modify elements in the data table and the data table will not receive updates when the Matrix, Vector, or Array assigned to the variable changes. In other words, it will be a snapshot in time that will not be updated. By default, the value is true.
Specifies if the names for the rows of the table are visible.
Specify names for the rows of the table.
The text that appears when the user hovers the mouse over the data table.
The type of the component. This returns "DataTable".
The variable that the data table is associated with. This may be a previously defined variable that has a Matrix, Vector, or Array assigned to it, or it may be a new variable that was created when the data table was created.
Specifies if the data table is visible. By default, the value is true.
The number of visible columns in the data table.
The number of visible rows in the data table.
Note: To interact with the examples provided below, open this help page as a worksheet and then execute the worksheet.
Example 1 - Create a function table and then plot the values
This example uses a DataTable component to display a set of points on a Plot component.
To insert the DataTable and Plot components using the Components palette:
Click on the DataTable icon in the Components palette.
In the Create Data Table dialog:
Select Create new Matrix
Set Total Columns and Visible Columns to 2
Set Total Rows and Visible Rows to 7
Click OK to close the Create Data Table dialog
Note: To change Row Name and Column Name, click the data table and make the changes in the Data Table context panel.
From the context panel for the data table, next to Column Name click Edit. Use Tab to highlight each entry and change the names to x and y.
Click on the Plot icon in the Components palette to insert the component.
For information on displaying the Maple palettes, see the Show Palettes help page.
To display the points in data table on the Plot component:
Click the DataTable component, and then from the Data Table context panel, select Edit Content Changed Code.
This launches the Code Editor.
Before the end use; statement in the dialog, enter the following command:
SetProperty("Plot0", value, plots:-pointplot(eval(parse(GetProperty("DataTable0", variableName))), color=red));
Note: Ensure the names of the components are correct (that is, that they match the Name fields of their components).
or from the File menu, select Save Code to accept all changes.
From the File menu, select Close Code Editor.
Enter the points in the data table (use Tab to go to the next cell). In this example, the points are for y= x2. When done, press Enter to generate a display on the Plot component.
Note: You can also use the data table to display points on a 3-D plot.
To do that:
Create a data table with 3 columns instead of 2.
In the code editor for data table, write the following command instead:
SetProperty("Plot0", value, plots:-pointplot3d(eval(parse(GetProperty("DataTable0", variableName))), color=red));
You can verify the syntax of the embedded component action by executing these commands in the worksheet in which you have defined the embedded components.
Error, (in DocumentTools:-GetProperty) Attempted to retrieve property of unknown component DataTable0. |lib/DocumentTools/src/GetProperty.mm:45|
SetProperty("Plot0", value, plots:-pointplot(eval(parse(GetProperty("DataTable0", 'variableName'))), 'color'=red));
Example 2 - Using a Data Table to Display an Array
In this example, we first define an array. Then we display that array in a data table. Because the data table is linked to the array, you can then retreive or change entries easily.
Define an array and assign it the name A. Type
This defines an 8 by 4 array and initializes each entry using a formula: the (i,j)th entry is i*j.
Select Use existing Matrix
If there is more than one Matrix, select A from the drop-down list.
The data table is inserted into the worksheet.
Remove the headers: from the context panel for the data table, clear the check boxes for Show Row Header and Show Column Header.
A ≔ Array⁡1..8,1..4,i,j→i⋅j:
To retrieve a value, type A[2,4];
To change a value, type A[2,4]:=0;
The (2,4)th entry in the data table is now zero.
A2,4 ≔ 0
Data tables in Maple are used in a number of places. For example, you can opt to embed a probability table into the worksheet, in which case the result is displayed in a data table. See Student[Statistics][ProbabilityTable].
Download Help Document
What kind of issue would you like to report? (Optional)