Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

read.mat

Read Matlab file


Description

Reads the values in a mat-file to a list.

Usage

read.mat(filename)

Arguments

filename

Character string, with the MAT file or URL to read.

Details

Reads the values in a mat-file and stores them in a list.

Value

A list with the variables read.

Note

  • A sparse complex matrix is read as a dense complex matrix.

  • A sparse logical matrix is read as a 'lgCMatrix'

  • A sparse matrix is read as a 'dgCMatrix'

  • A matrix of dimension 1 x n or n x 1 is read as a vector

  • A structure is read as a named list with fields.

  • A cell array is read as an unnamed list with cell data

  • A function class type is read as NULL and gives a warning.

See Also

See write.mat for more details and examples.

Examples

## Read a version 4 MAT file with little-endian byte ordering
filename <- system.file('extdata/matio_test_cases_v4_le.mat', package='rmatio')
m <- read.mat(filename)

## View content
str(m)

## Read a version 4 MAT file with big-endian byte ordering.
filename <- system.file('extdata/matio_test_cases_v4_be.mat', package='rmatio')
m <- read.mat(filename)

## View content
str(m)

## Read a compressed version 5 MAT file
filename <- system.file('extdata/matio_test_cases_compressed_le.mat', package='rmatio')
m <- read.mat(filename)

## View content
str(m)

rmatio

Read and Write 'Matlab' Files

v0.14.0
GPL-3
Authors
Stefan Widgren [aut, cre] (Author of the R interface to the C-library matio), Christopher Hulbert [aut] (Author of the C-library matio, http://sourceforge.net/projects/matio/)
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.