# Datasets and Functions

Often, parameters of components and parts are not single values but vary over time or voltage, or any other dimension. Valispace handles two-dimensional parameters with **Datasets** and **Functions**. Datasets are point-wise specifications of a varying Vali and Functions are defined by a formula and a variable range (which can also be from minus infinity to infinity). Datasets and Functions can be used in calculations and formulas of other Valis as usual and the results will be new Datasets or Functions. They can also be evaluated at a certain point where the value is well defined, e.g. Mass (5), where Mass is time-dependent (unit=s), results in the value of Mass at time T = 5s.

## Datasets

Datasets are point-wise specifications of a varying Vali. Datasets can also be measurements added to a Vali for reference. Users can create a dataset similar to creating a Vali and select the dataset.

Once the dataset Vali is created, select the dataset Vali **(1)**.** **The details tab opens and within the tab, the user can input the X-axis or Y-axis values. You also can import from CSV or XLSX **(2)**.

### Adding a Dataset

To add a dataset to a Vali, click the "convert to dataset" **(1)** button in the Vali details.

Add points to the dataset by adding a new row with the plus symbol underneath the table.

The variable will by default have the name "X" and no unit. You can change the name by clicking on the current name and typing a new name. You can change the unit by hovering over the name and clicking the settings symbol over the name cell.

### Interpolation and Extrapolation

Interpolation and extrapolation decide the values of the Vali between and beyond the specified points. It is used when datasets are used in calculations and evaluated.

Interpolation can be:

No interpolation - values are not defined between the points

Stepwise interpolation - constant value between points

Linear interpolation - linear function between points

Extrapolation can be:

No extrapolation - values are not defined outside of the data points range

Assume zero - values are all 0 outside of the data points range

Constant extrapolation - the values are constant outside of the data points range, defined by the first and last specified point

Continue interpolation - same extrapolation as specified interpolation

### Calculating with Datasets

When adding a dataset to a Vali, the formula will automatically be changed to `average_of_datasets()`

, which means that the result of the Vali used in calculations is the dataset. The Vali can be used in normal calculations, e.g. `Car.mass = sum_of_children()`

will sum up the masses of the subcomponents and if one of the subcomponents' masses is time-dependent `Car.mass`

will also become time-dependent. Mathematical operations on datasets always do the operation point-wise, e.g. `sqrt(Car.mass)`

will take the square root of each data point and the result itself will be a dataset.

## Functions

Valis can be a function by defining a formula dependent on a function variable, such as `vali = 2*X + 4`

. `X`

is a function variable with a name and unit. The function variable can be valid in its full (infinite) range or can be limited so that the function is only valid between a minimum and maximum value.

### Function variables

Function variables must start with a capital letter. `X`

, `T`

, and `Time`

are valid function variables while `time`

is not. The name of the function variable is global throughout all Valis, meaning that if `X`

is used in one function, it is the same `X`

used in another function.

### Calculating with functions

Functions can be calculated within the normal calculation. As an example, if `Vali1 = X^2`

and `Vali2 = 2*X`

then `Vali3 = $Vali1 + $Vali2`

will result in the function `X^2 + 2*X`

. If two Valis with different variables are used in a calculation the result will be a multi-dimensional function.

Valis are functions that can be evaluated at any valid point of the function variable. For example, if `Vali1 = X^2`

you can specify `Vali2 = $Vali1(1)`

which results in `Vali2 = 1`

.

History Tables for Datasets

The user can track the history/changes in the dataset Vali from version v1.52. You can access this option by clicking on the clock symbol in the details tab. The History tab also shows the time at which the dataset Vali has been changed and by which user. Also, the user has an additional column where the user can input the reasons for the change.

To see the dataset values, before and after, click on the small icon near the discussion to see the changes. Please refer to the gif on how you can see the history of datasets.