Problem when write dataset to h5 file: can only write a single number

Hi, I have a problem when write dataset to h5 file
I want to update a Dataset (/Sc/Data) in a .h5 file using matlab.
This “Data” is an unlimited variable length of 8-bit interger.

First I get the information about the data:

file = 'D:\QMDownload\5\20161212.h5'
fid = H5F.open(file,'H5F_ACC_RDWR','H5P_DEFAULT');
dset_id = H5D.open(fid,'/Sc/Data');           
aInfo = h5info(file,'/Sc/Data')

aInfo.Datatype:
          Name: ''
         Class: 'H5T_VLEN'
          Type: [1x1 struct]:
                                Name: ''
                                Class: 'H5T_INTEGER'
                                Type: 'H5T_STD_I8LE'
                                Size: 1
                                Attributes: []
          Size: 16
    Attributes: []
    
aInfo.Dataspace:
       Size: 1
    MaxSize: Inf
    Type: 'simple'

% then read the data:

data = H5D.read(dset_id);
 [1585x1 int8]

% then update the datav to int8 of [145,1678,189,167]

dataset_id = dset_id;
mem_type_id = 'H5ML_DEFAULT';
mem_space_id =  'H5S_ALL';
file_space_id = 'H5S_ALL';
plist_id = 'H5P_DEFAULT'
buf = int8([145,1678,189,167]);
H5D.write(dataset_id,mem_type_id,mem_space_id,file_space_id,plist_id,buf);

%=======
    Error using hdf5lib2
    The class of input data must be cell instead of int8 when the HDF5 class is H5T_VLEN.

    Error in H5D.write (line 71)
    H5ML.hdf5lib2('H5Dwrite', varargin{:});

%=======
    Then I use cell instead of matrix:
        buf = {int8(145);int8(167);int8(189);int8(167);};
        H5D.write(dataset_id,mem_type_id,mem_space_id,file_space_id,plist_id,buf);
        
        Error using hdf5lib2
        The number of elements in the memory space (1) does not correspond to the number of elements provided in
        the MATLAB array (4).

        Error in H5D.write (line 71)
        H5ML.hdf5lib2('H5Dwrite', varargin{:});

%=======
    It seems that I can only write a single number.
    I tried this:
        buf = {int8(145)};
        H5D.write(dataset_id,mem_type_id,mem_space_id,file_space_id,plist_id,buf);

    This time it worked, and I checked this file in hdf5viewer and indeed the Data was updated to a number 145.

Next I tried to write more than one number:

mem_space_id =  H5S.create_simple(1,length(buf),[])
H5D.write(dataset_id,mem_type_id,mem_space_id,file_space_id,plist_id,buf);

Error using hdf5lib2
The HDF5 library encountered an unknown error.
Error in H5D.write (line 71)
H5ML.hdf5lib2('H5Dwrite', varargin{:});


    The problem still exist that I cannot write more than one interger.
    Can anyone help me to solve this problem? Thanks.

solved by specifying buf as:
buf = {int8([145,1678,189,167])};