Writing custom classes and hdf5

5 vues (au cours des 30 derniers jours)
D. Plotnick
D. Plotnick le 27 Avr 2016
Commenté : D. Plotnick le 3 Mai 2016
I am currently building custom class containers for a complicated data set. I am using classdef to define properties and methods at a number of levels. The actual data is all in known matlab formats, struct,double,cell, etc.
The end result is a custom database. I want to then export that database as an HDF5 file. That way anyone can load in the data without needing my custom class definitions. Again, the actual components of the database are simple matlab classes. I do not need to export methods with the data.
I am looking for a way to do this. Currently, if I attempt to use hdf5write on my custom database I (unsurprisingly) get:
'Custom_Database' is not a valid datatype for HDF5WRITE
Any help is greatly appreciated. I'll include a MWE below:
classdef Custom_Database
properties
props1
props2
end
methods
function obj = Custom_Database(N)
obj.props1 = rand(N);
obj.props2 = 'Random';
end
function obj = Manipulate_DB(obj)
obj.props1 = 2*obj.props1-1;
obj.props2 = 'RandFull';
end
end
end
I create a database with
tstDB = Custom_Database(100)
Ok, so I wind up with some "Database" with an array and a string in it. I then want to write this to an HDF5 format, since all I want to give to the user is props1 and props2 in some structure. I may manipulate the data myself, but I don't need to keep the methods themselves. However,
hdf5write('test','/here',tstDB)
returns 'Custom_Database' is not a valid datatype for HDF5WRITE
  2 commentaires
per isakson
per isakson le 28 Avr 2016
Modifié(e) : per isakson le 28 Avr 2016
What release of Matlab do you use? Doc says: "Note: hdf5write will be removed in a future version. Use h5write instead."
Matlab high level functions can write numeric and character arrays to HDF5-files. You have to write a method that writes basic property values to the HDF5-file. See the documentation.
D. Plotnick
D. Plotnick le 3 Mai 2016
Currently 2015b, though I try to stay as up to date as time allows.

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by