How to: Insert an Array Field into Compound Dataset (MATLAB lowlevel h5)

I am trying to insert an array into my compound dataset

function h5ex_t_cmpdWArray
    fileName       = 'h5ex_t_cmpd.h5';
    DATASET        = 'DS1';
    DIM0           = 3;
    ADIM0          = 10;
    dims = DIM0;
    wdata.FieldA   =int32([1153 ; 1184 ; 1027 ]);
    wdata.FieldB    ={'Exterior (static)', 'Intake',...
    'Intake manifold'};
   % NEW: 3x10 
    wdata.FieldArray = [randn(1,ADIM0);randn(1,ADIM0);randn(1,ADIM0)];

%% Create a new file using the default properties.
file = H5F.create (fileName, 'H5F_ACC_TRUNC',...

%Create the required data types
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');
dimsArr = size(wdata.FieldArray);
arrayType = H5T.array_create(base_type_id, fliplr(dimsArr));
type_id = H5T.copy(base_type_id);
H5T.set_size(type_id, 16);
type_size = H5T.get_size(type_id);
%foo = H5T.get_size(arrayType);
sz(3) = type_size;

% Computer the offsets to each field. The first offset is always zero.

% Create the compound datatype for memory.
memtype = H5T.create ('H5T_COMPOUND', sum(sz));
H5T.insert (memtype,...
H5T.insert (memtype,...
    'FieldB',offset(2), strType);
H5T.insert (memtype,...
    'FieldArray',offset(3), type_id);
% Create the compound datatype for the file.  Because the standard
% types we are using for the file may have different sizes than
% the corresponding native types, we must manually calculate the
% offset of each member.
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), doubleType);

% Create dataspace.  Setting maximum size to [] sets the maximum
% size to be the current size.
space = H5S.create_simple (1,fliplr( dims), []);

% Create the dataset and write the compound data to it.
dset = H5D.create (file, DATASET, filetype, space, 'H5P_DEFAULT');
H5D.write (dset, memtype, 'H5S_ALL', 'H5S_ALL', 'H5P_DEFAULT', wdata);

% Close and release resources.
H5D.close (dset);
H5S.close (space);
H5T.close (filetype);
H5F.close (file);

Got error for
H5D.write (dset, memtype, ‘H5S_ALL’, ‘H5S_ALL’, ‘H5P_DEFAULT’, data);

Can anyone help