| Type: | Package |
| Title: | An Interface for MATLAB using System Calls |
| Version: | 1.5.2 |
| Date: | 2018-08-13 |
| Maintainer: | John Muschelli <muschellij2@gmail.com> |
| 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. |
| Imports: | stringr |
| License: | GPL-2 |
| Encoding: | UTF-8 |
| SystemRequirements: | MATLAB |
| BugReports: | https://github.com/muschellij2/matlabr/issues |
| RoxygenNote: | 6.1.0 |
| Suggests: | covr |
| NeedsCompilation: | no |
| Packaged: | 2018-08-13 16:00:55 UTC; johnmuschelli |
| Author: | John Muschelli [aut, cre] |
| Repository: | CRAN |
| Date/Publication: | 2018-08-13 16:30:05 UTC |
Create PATHs to add to MATLAB PATHs
Description
Create PATHs to add to MATLAB PATHs
Usage
add_path(path)gen_path(path)add_gen_path(path)Arguments
path | path to add |
Value
A character vector
Examples
add_path("~/")gen_path("~/")gen_path("~/")Find matlab path
Description
This tries to find matlab's path using a system whichcommand, and then, if not found, looks atgetOption("matlab.path"). If not path is found, it fails.
Usage
get_matlab(try_defaults = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, wait = TRUE, single_thread = FALSE)Arguments
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? |
wait | Should R wait for the command to finish. Bothpassed to |
single_thread | Should the flag |
Value
Character of command for matlab
Examples
if (have_matlab()) {get_matlab()}Logical check if MATLAB is accessible
Description
Usesget_matlab to check if MATLAB's path accessible
Usage
have_matlab()Value
LogicalTRUE is MATLAB is accessible,FALSE if not
Examples
have_matlab()Convert R matrix to matlab matrix
Description
This function takes in an R matrix then turns it into a matrix in matlab
Usage
rmat_to_matlab_mat(x, matname = NULL, transpose = FALSE)Arguments
x | matrix of values |
matname | Object in matlab to be assigned |
transpose | Transpose the matrix |
Value
Character scalar of matlab code
Runs matlab code
Description
This function takes in matlab code, wherethe last line must end with a ;, and returns the exitstatus
Usage
run_matlab_code(code, endlines = TRUE, verbose = TRUE, add_clear_all = FALSE, paths_to_add = NULL, ...)Arguments
code | Character vector of code. |
endlines | Logical of whether the semicolon (;) should bepasted 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 |
Value
Exit status of matlab code
Examples
if (have_matlab()){ run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), paths_to_add = "~/")}## Not run: if (have_matlab()){ 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)Run matlab script
Description
This function runs a matlab script, and returns exit statuses
Usage
run_matlab_script(fname, verbose = TRUE, desktop = FALSE, splash = FALSE, display = FALSE, wait = TRUE, single_thread = FALSE, ...)Arguments
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? |
wait | Should R wait for the command to finish. Bothpassed to |
single_thread | Should the flag |
... | Options passed to |
Value
Exit status of matlab code
Convert R vector to matlab cell mat
Description
This function takes in an R numeric and returns astatus
Usage
rvec_to_matlab(x, row = FALSE, sep = NULL, matname = NULL)Arguments
x | Numeric vector of values |
row | Create row vector instead of column vector |
sep | separator to use to separate cells. Will override rowargument |
matname | Object in matlab to be assigned |
Value
Character scalar of matlab code
Convert R vector to matlab cell
Description
This function takes in an R vector then turns it into a cell
Usage
rvec_to_matlabcell(x, sep = ";", matname = NULL, transpose = FALSE)Arguments
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 |
Value
Character scalar of matlab code
Convert R vector to matlab cell mat
Description
This function takes in an R vector then turns it into a cell list
Usage
rvec_to_matlabclist(x, matname = NULL)Arguments
x | Character vector of values |
matname | Object in matlab to be assigned |
Value
Character scalar of matlab code