| setFunction.Matlab {R.matlab} | R Documentation |
Creates an M-file on the Matlab server machine (in the working directory) containing the specified Matlab function definition.
## S3 method for class 'Matlab': setFunction(this, code, name=NULL, collapse=" ", ...)
code |
The Matlab function definition. |
name |
Optional name of the function, which will defined the
name of the M-file where the function is stored. If NULL,
the name is extracted from the code. |
collapse |
The string that the code lines, if there are more than one, is going to be concattenated with. |
... |
Not used. |
Returns nothing.
Henrik Bengtsson (http://www.braju.com/R/)
For more information see Matlab.
## Not run: code <- c(
"function [win,aver]=dice(B)",
"%Play the dice game B times",
"gains=[-1,2,-3,4,-5,6];",
"plays=unidrnd(6,B,1);",
"win=sum(gains(plays));",
"aver=win;"
)
setFunction(matlab, code)
evaluate(matlab, "[w,a]=dice(1000);")
res <- getVariable(matlab, c("w", "a"))
print(res)
## End(Not run)