Data Table Tutorial
Data Table Tutorial
A live version of this calculation is available at EngineeringPaper.xyz.
A video data table tutorial is also available. The data table cell type makes it easy to work with tabular data in EngineeringPaper.xyz. Data can be imported from Excel, CSV, or other spreadsheet file formats. The data can also be exported as a CSV file. To insert a data table cell, click the data table cell icon
Length | Width | Area=Length*Width= |
---|---|---|
[m] | [m] | [m^2] |
10 | 20 | 200 |
12 | 22 | 264 |
14 | 24 | 336 |
Each of the columns, input and output, gets assigned to its variable name as a column vector. For example the Length and Area columns are queried below:
$$ Length= \begin{bmatrix} 10\left\lbrack m\right\rbrack \ 12\left\lbrack m\right\rbrack \ 14\left\lbrack m\right\rbrack \end{bmatrix} $$
$$ Area= \begin{bmatrix} 200\left\lbrack m^2\right\rbrack \ 264\left\lbrack m^2\right\rbrack \ 336\left\lbrack m^2\right\rbrack \end{bmatrix} $$
Since the columns get assigned to vectors, functions that operate on vectors (min, max, average, stdev, etc.) can be used on the column variables. For example the maximum Area and the sum of all of the areas can be determined using the following query statements:
$$ \mathrm{min}\left(Area\right)= 200 \left\lbrack m^2\right\rbrack $$
$$ \mathrm{sum}\left(Area\right)= 800 \left\lbrack m^2\right\rbrack $$
In addition to performing calculations, data tables make it easy to create polynomial least squares fits to data. For example, the following data table fits a line to the provided x and y values. The linear fit can be used by calling the function called Polyfit1 (the function may be renamed by editing the function name field).
x_(points) | y_(points) |
---|---|
1 | 1.82236506 |
2 | 1.16819656 |
3 | 1.64634224 |
4 | 3.7461875 |
5 | 3.78533977 |
6 | 6.11934925 |
7 | 7.92414076 |
8 | 10.1906023 |
9 | 9.29269577 |
10 | 11.37309833 |
The plot below shows the original points as a scatter plot and the linear fit as a parametric plot (see the scatter plots and parametric plots tutorials for more information on defining these types of plots).
The Polyfit1 function that is created can be called like any other function as shown below:
$$ \mathrm{Polyfit1}\left(4\right)= 3.88485663163636 $$
The polynomial fit expression can be obtained by passing an undefined variable to the Polyfit1 function as shown below:
$$ \mathrm{Polyfit1}\left(x\right)= 1.21465008157576 \cdot x - 0.973743694666669 $$
Additionally, linear interpolation between table rows can performed automatically. In the following example, the Interp1 function can be used to provide the absolute viscosity of water as a function of temperature:
T_(points) | mu_(points) |
---|---|
[degC] | [cP] |
0 | 1.7918 |
20 | 1.0026 |
50 | 0.5471 |
100 | 0.2817 |
200 | 0.1346 |
The viscosity at 10 degrees Celsius between rows 1 and 2 can be obtained by a calling to the Interp1 function as shown below:
$$ \mathrm{Interp1}\left(10\left\lbrack degC\right\rbrack\right.)=\left\lbrack cP\right\rbrack =1.3972 \left\lbrack cP\right\rbrack $$
The following plot shows the points from the viscosity table above along with the Interp1 function showing the linear interpolation:
The range function is useful for initializing sequences of values in a data table. Calling range with one input creates a sequence that starts with 1 and ends with the provided value. Calling range with two inputs uses the first input as the starting value and the second value as the stopping value and increments the values by 1. Finally, calling range with three values uses the inputs as the starting value, stopping value, and increment value, in that order. See the example below:
Col1=range(5)= | Col2=range(-2,2) | range(0.2,1,0.2)= | Sum=Col1+Col2 |
---|---|---|---|
1 | -2 | 0.2 | -1 |
2 | -1 | 0.4 | 1 |
3 | 0 | 0.6 | 3 |
4 | 1 | 0.8 | 5 |
5 | 2 | 1 | 7 |
In the above example, the first two columns are assigned to the variable names Col1 and _Col2. _This allows the sum to be calculated in the last column using these two columns. The third column is set to range(0.2,1,0.2) but is not assigned to a variable so it cannot be used in other calculations. When assigning the calculation to a variable, the trailing equals sign is optional, as shown in the second column.