Tried this, but failed
dim = 4;
file = H5F.create (fileName, 'H5F_ACC_TRUNC',...
'H5P_DEFAULT', 'H5P_DEFAULT');
intType =H5T.copy('H5T_NATIVE_INT');
sz(1) = H5T.get_size(intType);
strType = H5T.copy ('H5T_C_S1');
H5T.set_size (strType, 'H5T_VARIABLE');
sz(2) =H5T.get_size(strType);
% array size
base_type_id = H5T.copy('H5T_NATIVE_DOUBLE');
arrayType = H5T.array_create(base_type_id, 1, ADIM0);
type_id = H5T.copy(arrayType);
H5T.set_size(type_id, 8);
sz(3) = H5T.get_size(arrayType);
intType =H5T.copy('H5T_NATIVE_INT');
sz(4) = H5T.get_size(intType);
offset(1)=0;
offset(2:4)=cumsum(sz(1:3));
memtype = H5T.create ('H5T_COMPOUND', sum(sz));
H5T.insert (memtype,...
'FieldA',offset(1),intType);
H5T.insert (memtype,...
'FieldB',offset(2), strType);
H5T.insert (memtype,...
'FieldArray',offset(3), arrayType);
H5T.insert (memtype,...
'FieldC',offset(4), intType);
filetype = H5T.create ('H5T_COMPOUND', sum(sz));
H5T.insert (filetype, 'FieldA', offset(1),intType);
H5T.insert (filetype, 'FieldB', offset(2), strType);
H5T.insert (filetype, 'FieldArray',offset(3), arrayType);
H5T.insert (filetype, 'FieldC',offset(4), intType);
space = H5S.create_simple (1,fliplr(dims), []);
dset = H5D.create (file, DATASET, filetype, space, 'H5P_DEFAULT');
H5D.write (dset, memtype, 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT', flip(wdata));