Writing custom classes and hdf5
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
per isakson
il 28 Apr 2016
Modificato: per isakson
il 28 Apr 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.
Risposte (0)
Vedere anche
Categorie
Scopri di più su HDF5 in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!