Reading Matlab files with R

MATLAB™ is a widely used professional tool for numerical processing used across multiple divers disciplines like Physics, Chemistry, and Mathematics. You can encounter multiple public data sets which are published in MATLAB™ format. This article gives a brief example of such data set and reading it from R.

The data set given here is provided by the NASA and contains multiple so called Flight Data Records (FDR), which are recordings of airplane data collected before, after and during each flight. The NASA has published a sample data set of multiple flight here. You can use this download script or take this adapted script which tracks download progress.

To read the data through R you first have to unzip them. Each flight contains multiple files and across multiple directories. To read for example all the files of flight 652, at least the first part we can iterate through all the files listed:

R Packages

CRAN holds at least two projects designed for working with MATLAB™ and it’s file format. There is R.matlab (PDF) or  RMatlab (PDF) which provide functional to R developers working with MATLAB™. R.matlab has a very simple interface to work with files that is why it has picked for this example. RMatlab on the other hands seems to provide very mature interfaces to interact with MATLAB™ directly.

Reading

Reading one of the files can simply be achieved like this:

Summary

Each files contains a collection of 86 parameter being collected over a certain amount of time in different intervals. Each parameter is a list of a values each being data, Ratio, Unit, Description, and Alpha. A quick summary of the file  reveals the contained parameters.

Exploring LONG

For the long parameter we get the following list elements:

Listing the data field values:

Further Readings

Leave a Reply