问题
I would like to run some Matlab scripts. Nevertheless we don't have the Matlab licence so it is necessary a conversion from Matlab to R language. Unfortunately I'm totally new in Matlab but not in R. Is it possible to read Matlab scripts using R or is there an easy way to translate Matlab scripts in R?
回答1:
Rewriting from one language to another can be a painstaking process, especially because your have to take great care that the outcomes of both sets of codes are the same. I see roughly four approaches:
- Digest the goal of the scripts, put aside the matlab code, and rewrite in R
- Try and mimic the matlab code in R
- Run the matlab code in octave, and interface with R
- Run the code in Octave entirely
These are roughly in order of amount of work. If you just want to get the Matlab code working, definitely use Octave, which should run the code with minimal changes. If you want to convert the code to R, and continue developing in R, I would go for the first option. In that way you can leverage the real strenghts of R, as R is quite different (link with info, comparison R and matlab). But it does take the largest amount of time. Even if you reimplement in R, I would recommend getting the code running in Octave to be able to see if your results in R fit with the Matlab code.
来源:https://stackoverflow.com/questions/12246309/how-to-convert-matlab-scripts-in-r