Data Class#

Data Class is a class to helps add or set data. Data can be addded using addData method. The addData method expects a cell array of cell array. Like other methods there’s a check that directs different cases based on the length of inputs (1 meaning only name or data entered. If only name is entered, error prompted saying ‘Single input is expected to be data name’. Case 2 being both name and data supplied and data is added accordingly). It uses table data type to do that. The dataTable is a table with 4 columns. The following are the 4 columns:

  1. Name of the data

  2. Second column is the data itself

  3. Data range. The data range is a cell array with two elements, the first element is the minimum value of the data, and the second element is the maximum value of the data. (optional)

  4. Simulation range. The simulation range is a cell array with two elements, the first element is the minimum value of the simulation, and the second element is the maximum value of the simulation. (optional)

Reference#

class API.projectClass.dataClass(name, data, dataRange, simRange)#

dataClass manages the datasets for the project. It provides methods to add, update and remove datasets. Each dataset is stored as a row in a table and consists of a name, the data itself, the range of the data to use, and the range for simulation.

Examples

If no arguments are provided, the object is created with an empty table.

>>> data = dataClass();

Otherwise, the arguments are used to create the first dataset.

>>> data = dataClass('Data 1', [1, 0, 0; 2, 0, 0; 3, 0, 0; 4, 0, 0], [2, 3], [1, 4]);
Parameters:
  • name (string or char array, default: '') – The name of the dataset.

  • data (float, default: []) – 3 or 4 column data for the dataset, the data should have (x, y, error) columns and may have an optional resolution column.

  • dataRange (float, default: default: [data(1, 1), data(end, 1)] or [] if no data) – The minimum and maximum range of data to use from the dataset.

  • simRange (float, default: default: [0.005, 0.7]) – The minimum and maximum range to use for simulation.

varTable#

A table object that contains the data entries.

Type:

table

addData(name, data, dataRange, simRange)#

Adds a new dataset to the data table.

Examples

To add a new dataset with name only.

>>> data.addData('Data 1');

To add dataset with name and data.

>>> data.addData('Data 1', [1, 0, 0; 2, 0, 0; 3, 0, 0; 4, 0, 0]);

To add dataset with name, data and the ranges.

>>> data.addData('Data 1', [1, 0, 0; 2, 0, 0; 3, 0, 0; 4, 0, 0], [2, 3], [1, 4]);
Parameters:
  • name (string or char array, default: auto-generated name) – The name of the dataset.

  • data (float, default: []) – 3 or 4 column data for the dataset, the data should have (x, y, error) columns and may have optional resolution column.

  • dataRange (float, default: [data(1, 1), data(end, 1)] or [] if no data) – The minimum and maximum range of data to use from the dataset.

  • simRange (float, default: [0.005, 0.7]) – The minimum and maximum range to use for simulation.

displayTable()#

Prints the data table to the console.

removeData(row)#

Removes a given dataset from the table.

Examples

To remove the second dataset in the table (dataset in row 2).

>>> data.removeData(2);

To remove dataset with a specific name.

>>> data.removeData('Data D2O');
Parameters:

row (string or char array or whole number) – If row is an integer, it is the row number of the dataset to remove. If it is text, it is the name of the dataset to remove.

setData(row, options)#

General purpose method for updating properties of an existing dataset.

Examples

To change the name and data of the second dataset in the table (dataset in row 2).

>>> nameChanged = data.setData(2, name='Data 1', data=[1, 0, 0; 2, 0, 0; 3, 0, 0; 4, 0, 0]);

To change the properties of a dataset called ‘Data 1’.

>>> nameChanged = data.setData('Data 1', name='Data H2O', dataRange=[2, 3]);
Parameters:
  • row (string or char array or whole number) – If row is an integer, it is the row number of the dataset to update. If it is text, it is the name of the dataset to update.

  • options

    Keyword/value pair to properties to update for the specific dataset.
    • name (char array or string, default: ‘’) the new name of the dataset.

    • data (float, default: []) the new data array.

    • dataRange (float, default: []) the new data range.

    • simRange (float, default: []) the new simulation range.

Returns:

nameChanged – A struct which contains the former name oldName and the new name newName of the dataset or an empty array if name is not changed.

Return type:

struct or []

toStruct()#

Converts the dataClass into a structure array.

Returns:

dataStruct – A struct which contains the properties for all the datasets.

Return type:

struct