Writing custom classes and hdf5
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
per isakson
2016-4-28
编辑:per isakson
2016-4-28
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Database Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!