1234567891011121314151617181920212223 |
- % NPY-MATLAB writeNPY function. Copied from https://github.com/kwikteam/npy-matlab
- function writeNPY(var, filename)
- % function writeNPY(var, filename)
- %
- % Only writes little endian, fortran (column-major) ordering; only writes
- % with NPY version number 1.0.
- %
- % Always outputs a shape according to matlab's convention, e.g. (10, 1)
- % rather than (10,).
- shape = size(var);
- dataType = class(var);
- header = constructNPYheader(dataType, shape);
- fid = fopen(filename, 'w');
- fwrite(fid, header, 'uint8');
- fwrite(fid, var, dataType);
- fclose(fid);
- end
|