run_matlab_code: Runs matlab code

Description Usage Arguments Value Examples

View source: R/matlab_script.R

Description

This function takes in matlab code, where the last line must end with a ;, and returns the exit status

Usage

1
2
3
4
5
6
7
8
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 be pasted to each element of the vector.

verbose

Print out filename to run

add_clear_all

Add clear all; to the beginning of code

paths_to_add

Character vector of PATHs to add to the script using add_path

...

Options passed to run_matlab_script

Value

Exit status of matlab code

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)

muschellij2/matlabr documentation built on July 4, 2020, 12:59 p.m.