read_mat: Read 'Matlab' files

View source: R/matlab.R

read_matR Documentation

Read 'Matlab' files

Description

A compatible reader that can read both 'Matlab' files prior and after version 6.0

Usage

read_mat(file, ram = TRUE)

read_mat2(file, ram = TRUE)

Arguments

file

path to a 'Matlab' file

ram

whether to load data into memory. Only available when the file is in 'HDF5' format. Default is false and will load arrays, if set to true, then lazy-load data. This is useful when array is very large.

Details

readMat can only read 'Matlab' files prior to version 6. After version 6, 'Matlab' uses 'HDF5' format to store its data, and read_mat can handle both cases.

The performance of read_mat can be limited when the file is too big or has many datasets as it reads all the data contained in 'Matlab' file into memory.

Value

A list of All the data stored in the file

See Also

readMat, load_h5

Examples


# Matlab .mat <= v7.3
x <- matrix(1:16, 4)
f <- tempfile()
R.matlab::writeMat(con = f, x = x)

read_mat(f)

# Matlab .mat >= v7.3, using hdf5
# Make sure you have installed hdf5r
if( dipsaus::package_installed('hdf5r') ){

f <- tempfile()
save_h5(x, file = f, name = 'x')

read_mat(f)

# For v7.3, you don't have to load all data into RAM
dat <- read_mat(f, ram = FALSE)
dat

dat$x[]

}




raveio documentation built on July 26, 2023, 5:29 p.m.