Title: | An Interface for MATLAB using System Calls |
---|---|
Description: | Provides users to call MATLAB from using the "system" command. Allows users to submit lines of code or MATLAB m files. This is in comparison to 'R.matlab', which creates a MATLAB server. |
Authors: | John Muschelli [aut, cre] |
Maintainer: | John Muschelli <[email protected]> |
License: | GPL-2 |
Version: | 1.6.0 |
Built: | 2024-11-15 02:50:07 UTC |
Source: | https://github.com/muschellij2/matlabr |
Create PATHs to add to MATLAB PATHs
add_path(path) gen_path(path) add_gen_path(path)
add_path(path) gen_path(path) add_gen_path(path)
path |
path to add |
A character vector
add_path("~/") gen_path("~/") gen_path("~/")
add_path("~/") gen_path("~/") gen_path("~/")
This tries to find matlab's path using a system which
command, and then, if not found, looks at getOption("matlab.path")
. If not path is found, it fails.
get_matlab( try_defaults = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, jvm = TRUE, figure_windows = TRUE, wait = TRUE, single_thread = FALSE )
get_matlab( try_defaults = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, jvm = TRUE, figure_windows = TRUE, wait = TRUE, single_thread = FALSE )
try_defaults |
(logical) If |
desktop |
Should desktop be active for MATLAB? |
splash |
Should splash be active for MATLAB? |
display |
Should display be active for MATLAB? |
jvm |
should JVM be be loaded? If |
figure_windows |
should figure windows be enabled. If
not, |
wait |
Should R wait for the command to finish. Both
passed to |
single_thread |
Should the flag |
Character of command for matlab
if (have_matlab()) { get_matlab() }
if (have_matlab()) { get_matlab() }
Uses get_matlab
to check if
MATLAB's path accessible
have_matlab()
have_matlab()
Logical TRUE
is MATLAB is accessible, FALSE
if not
have_matlab()
have_matlab()
This function takes in an R matrix then turns it into a matrix in matlab
rmat_to_matlab_mat(x, matname = NULL, transpose = FALSE)
rmat_to_matlab_mat(x, matname = NULL, transpose = FALSE)
x |
matrix of values |
matname |
Object in matlab to be assigned |
transpose |
Transpose the matrix |
Character scalar of matlab code
This function takes in matlab code, where the last line must end with a ;, and returns the exit status
run_matlab_code( code, endlines = TRUE, verbose = TRUE, add_clear_all = FALSE, paths_to_add = NULL, ... )
run_matlab_code( code, endlines = TRUE, verbose = TRUE, add_clear_all = FALSE, paths_to_add = NULL, ... )
code |
Character vector of code. |
endlines |
Logical of whether the semicolon (;) should be pasted to each element of the vector. |
verbose |
Print out filename to run |
add_clear_all |
Add |
paths_to_add |
Character vector of PATHs to add to the
script using |
... |
Options passed to |
Exit status of matlab code
if (have_matlab()){ run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), paths_to_add = "~/") } ## Not run: if (have_matlab()){ system.time({ run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), jvm = FALSE, figure_windows = FALSE) }) run_matlab_code("disp(version)") run_matlab_code("disp(version)", paths_to_add = "~/") run_matlab_code(c("x = 5", "disp(['The value of x is ', num2str(x)])")) } ## End(Not run)
if (have_matlab()){ run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), paths_to_add = "~/") } ## Not run: if (have_matlab()){ system.time({ run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), jvm = FALSE, figure_windows = FALSE) }) run_matlab_code("disp(version)") run_matlab_code("disp(version)", paths_to_add = "~/") run_matlab_code(c("x = 5", "disp(['The value of x is ', num2str(x)])")) } ## End(Not run)
This function runs a matlab script, and returns exit statuses
run_matlab_script( fname, verbose = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, jvm = TRUE, figure_windows = TRUE, wait = TRUE, single_thread = FALSE, ... )
run_matlab_script( fname, verbose = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, jvm = TRUE, figure_windows = TRUE, wait = TRUE, single_thread = FALSE, ... )
fname |
Filename of matlab script (.m file) |
verbose |
print diagnostic messages |
desktop |
Should desktop be active for MATLAB? |
splash |
Should splash be active for MATLAB? |
display |
Should display be active for MATLAB? |
jvm |
should JVM be be loaded? If |
figure_windows |
should figure windows be enabled. If
not, |
wait |
Should R wait for the command to finish. Both
passed to |
single_thread |
Should the flag |
... |
Options passed to |
Exit status of matlab code
This function takes in an R numeric and returns a status
rvec_to_matlab(x, row = FALSE, sep = NULL, matname = NULL)
rvec_to_matlab(x, row = FALSE, sep = NULL, matname = NULL)
x |
Numeric vector of values |
row |
Create row vector instead of column vector |
sep |
separator to use to separate cells. Will override row argument |
matname |
Object in matlab to be assigned |
Character scalar of matlab code
This function takes in an R vector then turns it into a cell
rvec_to_matlabcell(x, sep = ";", matname = NULL, transpose = FALSE)
rvec_to_matlabcell(x, sep = ";", matname = NULL, transpose = FALSE)
x |
Character vector of values |
sep |
separator to use to separate values. Defaults to ";" argument |
matname |
Object in matlab to be assigned |
transpose |
Transpose the cell |
Character scalar of matlab code
This function takes in an R vector then turns it into a cell list
rvec_to_matlabclist(x, matname = NULL)
rvec_to_matlabclist(x, matname = NULL)
x |
Character vector of values |
matname |
Object in matlab to be assigned |
Character scalar of matlab code