setFunction.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="\n", ...)
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 |
collapse |
The string that the code lines, if there are more than one, is going to be concatenated with. |
... |
Not used. |
Returns nothing.
Henrik Bengtsson
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.