-
Notifications
You must be signed in to change notification settings - Fork 0
Tutorial 2 ( Creating the first database )
All tutorials assume that you have the HDS-Toolbox installed in Matlab
In this tutorial, we will create a database based on the example HDS-classes that are provided with the HDS-Toolbox. We will create a database, add a variety of objects and data, save the database and reload parts of the database from disk. The class definitions are in the Examples folder. You can create your own class hierarchy using the HDSTemplate.m file in the @HDSTemplate folder.
Step 1: Create new object Each database must have a single 'host'-object. This object is the top of the hierarchical data structure and will contain links to one or more 'child'-objects. From tutorial 1, we know that the 'exMain' class defines objects at the top of the hierarchy, so let's create a variable that contains an object of this class:
M = exMain
M.dbName = 'This is a test database'
What we did is that we defined a variable (M) as an object of class 'exMain'. We subsequently populated the 'dbName' property of the object with a string (This is optional).
% Add a child object and 5 Experiment objects
addobj(M, 'exSubject')
S = M.subj(1)
addobj(S, 'exExperiment', 5)
The toolbox includes a small application that monitors how many resources the HDS-Toolbox uses. To open this monitor, type
hdsmonitor
Using this monitor, you can see that you created
% View 3 experiment
M.subj(1).exp(3)
% Save data (choose empty folder)
save(M)
% Clear workspace; hdsmonitor shows that objects are removed from memory
clear all
% Load object; select the 'exMain.mat' file. Notice that only one object is loaded
M = hdsload
% Access second experiment; notice that objects are loaded as needed.
M.subj(1).exp(2)
This is a very short introduction to the possibilities of the database. There is additional information in the help files that are accessible in the Matlab help (HDS-Toolbox). More information will be provided as the project matures.