Anton Sylchenko
2013-Dec-24 19:44 UTC
[R] Transferring data from R to MATLAB via Rmatlab package
Hi all, I spent a whole day on the internet trying to figure this out but no luck, so I was wondering if anyone would be able to help me. I am running code that requires me set up variables in R, establish a connection to MATLAB, set matlab variables based on the previous variables in R via the connection, close the connection, and then use the established variables for analysis in MATLAB. I set up the server through MATLAB by adding the path that contains MatlabServer.m, and I got this in MATLAB:>> MatlabServerRunning MatlabServer v1.3.5 MATLAB v7.x or higher detected. Saving with option -V6. Added InputStreamByteWrapper to dynamic Java CLASSPATH. ---------------------- MATLAB server started! ---------------------- Trying to open server socket (port 9999)...done. After this, I install and load R.oo, R.utils, and R.matlab into R, and enter: matlab <- Matlab() isOpen <- open(matlab) Sys.sleep(15) print(matlab) then I set the variables and close the connection. in my MATLAB window, each variable comes through like this: Received cmd: 3 Will read MAT file: "/var/folders/4c/s3s3b1rx2yq8n3blvp27cmtw0000gn/T//RtmpvXWCry/file45dbfd4ac9.mat" however, once i close the connection and try to run matlab code (in matlab) that uses these variables, they are all undefined and i get an error. How do I fix this ? The majority of my code is in Matlab and I can't continue without these variables. The R.matlab package pdf said something about needing to establish a remote connection in order for the values to be stored but I don't know how to do this either....R tells me the connection is remote=FALSE so it seems this is the default. Can anyone please help me with this ? Any advice would be greatly appreciated. Even if there is a better way to do this, that would be OK because I just need the variables to go through. [[alternative HTML version deleted]]