Email: helpdesk@telkomuniversity.ac.id

This Portal for internal use only!

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Categories
  • Microsoft
    • Microsoft Apps
    • Office
    • Operating System
    • VLS
    • Developer Tools
    • Productivity Tools
    • Database
    • AI + Machine Learning
    • Middleware System
    • Learning Services
    • Analytics
    • Networking
    • Compute
    • Security
    • Internet Of Things
  • Adobe
  • Matlab
  • Google
  • Visual Paradigm
  • WordPress
    • Plugin WP
    • Themes WP
  • Opensource
  • Others
More Categories Less Categories
  • Get Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • My Account
    • Download
    • Cart
    • Checkout
    • Login
  • About Us
    • Contact
    • Forum
    • Frequently Questions
    • Privacy Policy
  • Forum
    • News
      • Category
      • News Tag

iconTicket Service Desk

  • My Download
  • Checkout
Application Package Repository Telkom University
All Categories

All Categories

  • IBM
  • Visual Paradigm
  • Adobe
  • Google
  • Matlab
  • Microsoft
    • Microsoft Apps
    • Analytics
    • AI + Machine Learning
    • Compute
    • Database
    • Developer Tools
    • Internet Of Things
    • Learning Services
    • Middleware System
    • Networking
    • Operating System
    • Productivity Tools
    • Security
    • VLS
      • Office
      • Windows
  • Opensource
  • Wordpress
    • Plugin WP
    • Themes WP
  • Others

Search

0 Wishlist

Cart

Menu
  • Home
    • Download Application Package Repository Telkom University
    • Application Package Repository Telkom University
    • Download Official License Telkom University
    • Download Installer Application Pack
    • Product Category
    • Simple Product
    • Grouped Product
    • Variable Product
    • External Product
  • All Pack
    • Microsoft
      • Operating System
      • Productivity Tools
      • Developer Tools
      • Database
      • AI + Machine Learning
      • Middleware System
      • Networking
      • Compute
      • Security
      • Analytics
      • Internet Of Things
      • Learning Services
    • Microsoft Apps
      • VLS
    • Adobe
    • Matlab
    • WordPress
      • Themes WP
      • Plugin WP
    • Google
    • Opensource
    • Others
  • My account
    • Download
    • Get Pack
    • Cart
    • Checkout
  • News
    • Category
    • News Tag
  • Forum
  • About Us
    • Privacy Policy
    • Frequently Questions
    • Contact
Home/Matlab/HDF Compound Data and “strings”

HDF Compound Data and “strings”

PuTI / 2025-02-04
HDF Compound Data and “strings”
Matlab News

Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.

So, is there a way to keep the strings and if so, what am I missing?

%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;

%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;

fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end

H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);

dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid)Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.

So, is there a way to keep the strings and if so, what am I missing?

%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;

%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;

fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end

H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);

dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid) Hi,
I’m migrating code to Matlab. The data format from the previous language writes out an HDF file, with a compound datatype. This is not the way I would choose to do this in Matlab, I love the higher level functions and almost never touch the lower level ones. However, I’d like to make the new code backwards compatible with previous data which means I also need the compound datatype. It includes strings. I know HDF supports this, but it’s unclear that Matlab supports putting this into an HDF file.
The error message I get is:
Error using hdf5lib2
The class of input data must be integer instead of char when the HDF5 class is H5T_STD_I8LE.
Error in H5D.write (line 100)
H5ML.hdf5lib2(‘H5Dwrite’, varargin{:});
Error in hdfhell2p0 (line 53)
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

I can only assume it’s upset by the char arrays/strings. I’ve tried different versions of creating the strings. I found a piece that said they had to be characters, not strings, so I converted them. I found another that said they had to be uniform in length, so I set a specific length. This one doesn’t make sense to me since I’m only doinn a single value, but hey, grasping at straws.
If i remove the strings/charcters, it works.

So, is there a way to keep the strings and if so, what am I missing?

%%make up a mixed structure
params.floc = ‘C:Folder1’;
params.fname = ‘fname.txt’;
params.value = 10;

%%actual code
outname = ‘test09.h5’;
plist = ‘H5P_DEFAULT’;

fNames = fieldnames(params);
for ii = 1:numel(fNames)
temp = params.(fNames{ii});
if ~isnan(str2double(temp))
params.(fNames{ii}) = str2double(temp);
Vsize(ii) = 8;
Vclass{ii} = ‘H5T_NATIVE_DOUBLE’;
elseif ischar(temp)
temp = char(pad(params.(fNames{ii}),15,’right’));
params.(fNames{ii}) = temp;
Vsize(ii) = strlength(temp);
Vclass{ii}= ‘H5T_NATIVE_CHAR’;
end
end

H5F.create(outname, ‘H5F_ACC_TRUNC’, ‘H5P_DEFAULT’, ‘H5P_DEFAULT’);
fid = H5F.open(outname,’H5F_ACC_RDWR’,plist);
H5G.create(fid,’/SETTINGS’,plist,plist,plist);
gid = H5G.open(fid,’/SETTINGS’);
cid = H5T.create(‘H5T_COMPOUND’, sum(Vsize));
for ii = 1:numel(fNames)
if ii == 1
H5T.insert(cid, fNames{ii}, 0, H5T.copy(Vclass{ii}));
else
if strcmp(Vclass{ii},’H5T_NATIVE_CHAR’)
string_type = H5T.array_create(H5T.copy(‘H5T_NATIVE_CHAR’), 1, 20);
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), string_type)
else
H5T.insert(cid, fNames{ii}, sum(Vsize(1:(ii-1))), H5T.copy(Vclass{ii}));
end
end
end
dsid = H5S.create_simple(1,1,[]);

dsetid = H5D.create(fid, ‘/SETTINGS/PASS’, cid, dsid, ‘H5P_DEFAULT’);
H5D.write(dsetid, cid, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, params);

H5D.close(dsetid)
H5S.close(did)
H5T.close(cid)
H5G.close(gid)
H5F.close(fid) h5, hdf, compound data type, strings and hdf MATLAB Answers — New Questions

​

Tags: matlab

Share this!

Related posts

How to create excel sheet for developed model using MATLAB
2025-05-16

How to create excel sheet for developed model using MATLAB

How to express constants of integral
2025-05-16

How to express constants of integral

2019b download installer
2025-05-16

2019b download installer

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Search

Categories

  • Matlab
  • Microsoft
  • News
  • Other
Application Package Repository Telkom University

Tags

matlab microsoft opensources
Application Package Download License

Application Package Download License

Adobe
Google for Education
IBM
Matlab
Microsoft
Wordpress
Visual Paradigm
Opensource

Sign Up For Newsletters

Be the First to Know. Sign up for newsletter today

Application Package Repository Telkom University

Portal Application Package Repository Telkom University, for internal use only, empower civitas academica in study and research.

Information

  • Telkom University
  • About Us
  • Contact
  • Forum Discussion
  • FAQ
  • Helpdesk Ticket

Contact Us

  • Ask: Any question please read FAQ
  • Mail: helpdesk@telkomuniversity.ac.id
  • Call: +62 823-1994-9941
  • WA: +62 823-1994-9943
  • Site: Gedung Panambulai. Jl. Telekomunikasi

Copyright © Telkom University. All Rights Reserved. ch

  • FAQ
  • Privacy Policy
  • Term

This Application Package for internal Telkom University only (students and employee). Chiers... Dismiss