A Code Converter from the Matlab/Octave Language to R

Transferring over a code base from Matlab to R is often a repetitive and inefficient use of time. This package provides a translator for Matlab / Octave code into R code. It does some syntax changes, but most of the heavy lifting is in the function changes since the languages are so similar. Options for different data structures and the functions that can be changed are given. The Matlab code should be mostly in adherence to the standard style guide but some effort has been made to accommodate different number of spaces and other small syntax issues. This will not make the code more R friendly and may not even run afterwards. However, the rudimentary syntax, base function and data structure conversion is done quickly so that the maintainer can focus on changes to the design structure.

A Utility to Convert Matlab / Octave Code into R Code

The time and headaches that come from migrating legacy code into a new language keeps many from transitioning to R. There are methods to call Matlab code in R, or call Matlab directly in R. There isn't a good translator for the code it self. There are times when you choose the wrong coding language for a project or when you want to migrate a large code base where doing the small differences between languages takes too much time and energy. This program tries to make that move easier by doing the rudimentary things automatically. R and Matlab are so similar in scope and purpose that such a translator can do more than change syntax but also migrate compatible base functions and choose new data structures for some of the variables.

The code consists of a wrapper function, 'mat2r' to do the various parts of the translation. It does syntax changes automatically, but the function and data converters have to be passed to it directly. These are made with the functions "makeFuncMaps", "makeDataMap" and "makeSliceMap" and are passed to the main driver as a list. This makes it so that a translation can be as precise and customized to each individual projects needs.



For the most up to date version you can go to the development version using:


For a detailed look into how to use this package you can look at the vignettes:

rmarkdown::render(paste(system.file(package="matconv"), "vignettes/basicSyntax.rmd", sep="/"))
rmarkdown::render(paste(system.file(package="matconv"), "vignettes/functionCalls.rmd", sep="/"))
rmarkdown::render(paste(system.file(package="matconv"), "vignettes/overallUse.rmd", sep="/"))


Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.


0.4.0 by Siddarta Jairam, a year ago

Browse source code at https://github.com/cran/matconv

Authors: Siddarta Jairam [aut, cre] , David Hiebeler [ctb]

Documentation:   PDF Manual  

GPL (>= 2) license

Imports methods

Suggests knitr, testthat

See at CRAN