Skip to content
Prev 106277 / 398506 Next

Query regarding linking R with Matlab

Hi,

what operating system are you on and what version of Matlab do you have?

In general you should be able to get started with R.matlab by first
installing all required packages from CRAN:

install.packages(c("R.oo", "R.utils", "R.matlab"))

Then load the package:

library(R.matlab)
# Create a Matlab client
matlab <- Matlab(host="localhost", port=9998)

# Connect to the Matlab server
if (!open(matlab))
  throw("Matlab server is not running: waited 30 seconds.")

# Run Matlab expressions on the Matlab server
res <- evaluate(matlab, "A=1+2;", "B=ones(2,20);")

# Get Matlab variables
data <- getVariable(matlab, c("A", "B"))
cat("Received variables:\n")
str(data)

...

# When done, close the Matlab client, which will also shutdown
# the Matlab server and the connection to it.
close(matlab)

Hope this helps

Henrik
On 12/15/06, Bhanu Kalyan.K <kalyansikha at yahoo.com> wrote: