vendredi 30 janvier 2015

Calling R function within Matlab and loading Matlab variables into the R function


Vote count:

0




I am calling R script from within Matlab. The R script is a function that should load the data generated from Matlab and then passes it through the R function, and finally computes a result and sends it back to Matlab. I have included a very simplified code below. The Matlab and R file are in the same path. The R_script.R is the following:



require("mclust")
group = function(data, num_cls){
Mclustmodel = Mclust(data, num_cls)
return(Mclustmodel$class)
}


In Matlab, the code is:



system( 'Rscript ./R_script.R' )
X = rand(10);
K = 3;
class = group(X, K) % Question: Can I load X and K into the R function group, and directly calculate the answer?


I am using a Linux system.


Thanks.



asked 1 min ago







Calling R function within Matlab and loading Matlab variables into the R function

Aucun commentaire:

Enregistrer un commentaire