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:
Name of the data
Second column is the data itself
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)
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)
Method in Project Class |
Method in Data Class |
---|---|
projectClass.addData() |
dataClass.addData() |
projectClass.setData() |
dataClass.setData() |
Like other classes, it has methods to setData, setDataRange or any individual column/parameter. It also checks if the data given is in the right format, and if so, it stores it. If not, it has proper conditional statements to pinpoint the error. Like warning about duplicate names, number of inputs, type of an input .. etc.
D2O_data = readmatrix('c_PLP0016596.dat');
% Add the data to the project
projectClass.addData('Bilayer / D2O', D2O_data(:,1:3));
problem.setData(2,'dataRange',[0.013 0.35]);
Reference#
- class API.projectClass.dataClass(varargin)#
- addData(varargin)#
Adds a dataset to the data table. Default values are used if no arguments are provided, otherwise a subset of the arguments can be provided. The following are assumed from number of arguments: for 1 input, the name only is provided for 2 inputs, the name and data are provided for 4 inputs, the name, data, data range, and simulation range are provided
data.addData(); data.addData(‘Sim’); data.addData(‘Sim’, ones(5, 3)); data.addData(‘Sim’, ones(5, 3), [0.2, 0.9], [-3, 6]);
- dataClass(varargin)#
Creates a Data object. The argument should be contents of the first dataset which should consists of a name (string), data (N by 3 array), dataRange (1 by 2 or empty array), and simRange (1 by 2 or empty array).
data = dataClass(‘data_name’, [], [], []);
- displayTable()#
Displays the table object. The actual obj.varTable has the format {string, cell, double, double}, but for display we make a table that is all strings.
- setData(row, varargin)#
Sets the values of an existing dataset. Expects the index or name of dataset and keyword/value pairs to set
data.setData(2, ‘name’, ‘new_name’);
- setDataName(whichData, name)#
Sets the name of an existing dataset. Expects index of data and the new name. Name must be a char and not an existing name. Returns a structure with the new name and old name
names = data.setDataName({2, ‘new name’});
- static validateData(row)#
Carry out checks of Data type and ranges in a table row. Expects the row of the data table as input.
row = obj.validateData(row);