h5write — Write dense numeric, logical, string, or char data to an HDF5 dataset.
h5write(filename, dataset, data) creates a dense dataset (and intermediate groups) or overwrites an existing dataset of matching shape. Start/count and optional stride select a hyperslab in an existing dataset.
Syntax
h5write(filename, dataset, data)
h5write(filename, dataset, data, start, count[, stride])Inputs
filename- Type
StringScalar- Required
- Yes
- Description
- HDF5 file name.
dataset- Type
StringScalar- Required
- Yes
- Description
- Dataset path in the file.
data- Type
Any- Required
- Yes
- Description
- Data to write.
start- Type
NumericArray- Required
- Yes
- Description
- One-based starting subscript for each HDF5 dimension.
count- Type
NumericArray- Required
- Yes
- Description
- Number of elements to write in each dimension.
stride- Type
NumericArray- Required
- No
- Description
- Stride for each HDF5 dimension.
Errors
RunMat:hdf5:InvalidArgument- When
- Filename, object paths, selection vectors, or values are malformed.
- Message
hdf5: invalid argument
RunMat:hdf5:Io- When
- The HDF5 file cannot be opened, read, written, or traversed.
- Message
hdf5: file I/O failed
RunMat:hdf5:UnsupportedType- When
- The HDF5 type or MATLAB value is outside the supported dense numeric, logical, or string subset.
- Message
hdf5: unsupported type
Behavior
Double, single, exact signed/unsigned integer, logical, string, and char values are admitted; native numeric storage is preserved. Numeric, logical, and string array dimensions are preserved in HDF5 row-major storage. String values and character rows are written as UTF-8 variable-length strings. Partial writes require data shape to match count.
Sparse, complex, cell, struct, object, and handle values report RunMat:hdf5:UnsupportedType. Known-invalid data and selection controls reject before native file access. Admitted GPU-resident numeric data is materialized to host; native HDF5 I/O has no GPU kernel or fusion route. Browser execution rejects with RunMat:hdf5:UnsupportedTarget.
Execution and placement
Native HDF5 file access is synchronous host work. It terminates fusion and does not launch a GPU kernel. The active native filesystem path authority and HDF5 library must be available; a missing native route reports a typed error rather than falling back to an unrelated ambient path.
Example
h5write with a deterministic native HDF5 file
h5write('out.h5', '/A', magic(3));
A = h5read('out.h5', '/A');
AUsing h5write with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how h5write changes the result.
Run a small h5write example, explain the result, then change one input and compare the output.
FAQ
Can this run in a browser?⌄
The current HDF5 backend requires a native HDF5 library; browser calls return RunMat:hdf5:UnsupportedTarget.
Related Io functions
Repl Fs
addpath · cd · copyfile · delete · dir · exist · fileattrib · fileparts · filesep · fullfile · genpath · getenv · getpref · isenv · isfile · isfolder · ispref · ls · matlabroot · memmapfile · memmapfile.subsasgn · memmapfile.subsref · mkdir · movefile · open · opentoline · path · pathsep · pcode · pwd · readstruct · rehash · restoredefaultpath · rmdir · rmpath · run · savepath · setenv · setpref · system · tempdir · tempname · uigetdir · uigetfile · uiputfile · unsetenv · userpath · what · winqueryreg · xmlread · xmlwrite
Tabular
arrayDatastore · csvread · csvwrite · detectImportOptions · dlmread · dlmwrite · fileDatastore · getvaropts · parquetDatastore · parquetinfo · parquetread · readcell · readmatrix · readtable · readtimetable · setvaropts · setvartype · spreadsheetImportOptions · writecell · writematrix · writetable · writetimetable · xlsread · xlswrite
Data
commit · data.copy · data.create · data.delete · data.exists · data.export · data.import · data.inspect · data.list · data.move · data.open · DataArray.chunk_shape · DataArray.codec · DataArray.dtype · DataArray.fill · DataArray.name · DataArray.rank · DataArray.read · DataArray.resize · DataArray.shape · DataArray.write · Dataset.array · Dataset.arrays · Dataset.attrs · Dataset.begin · Dataset.get_attr · Dataset.has_array · Dataset.id · Dataset.path · Dataset.refresh · Dataset.set_attr · Dataset.set_attrs · Dataset.snapshot · Dataset.version · DataTransaction.abort · DataTransaction.commit · DataTransaction.create_array · DataTransaction.delete_array · DataTransaction.fill · DataTransaction.id · DataTransaction.resize · DataTransaction.set_attr · DataTransaction.set_attrs · DataTransaction.status · DataTransaction.write
Filetext
fclose · feof · fgetl · fgets · fileread · filewrite · fopen · fprintf · fread · frewind · fwrite · readlines · writelines
Import
Json
Source you can read
Every RunMat function's source is public. Read exactly how h5write is executed, line by line, in Rust.
- View the source for h5write in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.