├── .Rbuildignore ├── .gitignore ├── .travis.yml ├── DESCRIPTION ├── NAMESPACE ├── NEWS.md ├── R ├── add_path.R ├── matlab_script.R ├── rmat_to_matlab_mat.R ├── rvec_to_matlab.R └── rvec_to_matlabcell.R ├── README.Rmd ├── README.md ├── appveyor.yml ├── codecov.yml ├── cran-comments.md ├── man ├── add_path.Rd ├── get_matlab.Rd ├── have_matlab.Rd ├── rmat_to_matlab_mat.Rd ├── run_matlab_code.Rd ├── run_matlab_script.Rd ├── rvec_to_matlab.Rd ├── rvec_to_matlabcell.Rd └── rvec_to_matlabclist.Rd └── matlabr.Rproj /.Rbuildignore: -------------------------------------------------------------------------------- 1 | ^.*\.Rproj$ 2 | ^\.Rproj\.user$ 3 | ^\.travis\.yml$ 4 | 5 | ^appveyor\.yml$ 6 | ^codecov\.yml$ 7 | ^README\.Rmd$ 8 | ^README-.*\.png$ 9 | ^cran-comments\.md$ 10 | ^CONDUCT\.md$ 11 | ^README\.html$ 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .Rproj.user 2 | .Rhistory 3 | .RData 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: r 2 | warnings_are_errors: yes 3 | sudo: false 4 | cache: packages 5 | notifications: 6 | email: 7 | on_success: change 8 | on_failure: change 9 | after_success: 10 | - if [ "$TRAVIS_OS_NAME" == "linux" ]; then 11 | Rscript -e 'covr::coveralls(type = "all")'; 12 | fi 13 | before_deploy: 14 | - if [ "$TRAVIS_OS_NAME" == "osx" ]; then rm -f *.tar.gz; fi 15 | r_check_args: --as-cran --install-args=--build--as-cran --install-args=--build 16 | 17 | deploy: 18 | provider: releases 19 | skip_cleanup: yes 20 | file_glob: yes 21 | file: matlabr*.t*gz 22 | api_key: 23 | secure: feEQfSdWE8iN6Wl0E0rf8kdM1Z0Gcy5lNd854bB8UEO7O+kGgSc5oGdqCSF1Iys1VCdoG+w5Q2YMuvQUiOGOGW/OTdyu9lLk5Rim/TN4kSiIpDdIcBg9TK9P/F0G/IkzpdznxMQYFoXVDDZMAEZhrF6p5HDQVqz5bUrys0yfymg= 24 | file_glob: yes 25 | 'on': 26 | tags: yes 27 | repo: muschellij2/matlabr 28 | 29 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: matlabr 2 | Type: Package 3 | Title: An Interface for MATLAB using System Calls 4 | Version: 1.6.0 5 | Date: 2020-07-01 6 | Authors@R: person(given = "John", 7 | family = "Muschelli", 8 | role = c("aut", "cre"), 9 | email = "muschellij2@gmail.com") 10 | Maintainer: John Muschelli 11 | Description: Provides users to call MATLAB from using the "system" command. 12 | Allows users to submit lines of code or MATLAB m files. 13 | This is in comparison to 'R.matlab', which creates a MATLAB server. 14 | Imports: 15 | stringr 16 | License: GPL-2 17 | Encoding: UTF-8 18 | SystemRequirements: MATLAB 19 | BugReports: https://github.com/muschellij2/matlabr/issues 20 | RoxygenNote: 7.1.0 21 | Suggests: covr 22 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | # Generated by roxygen2: do not edit by hand 2 | 3 | export(add_gen_path) 4 | export(add_path) 5 | export(gen_path) 6 | export(get_matlab) 7 | export(have_matlab) 8 | export(rmat_to_matlab_mat) 9 | export(run_matlab_code) 10 | export(run_matlab_script) 11 | export(rvec_to_matlab) 12 | export(rvec_to_matlabcell) 13 | export(rvec_to_matlabclist) 14 | import(stringr) 15 | -------------------------------------------------------------------------------- /NEWS.md: -------------------------------------------------------------------------------- 1 | # CHANGES IN matlabr VERSION 1.6.0 2 | 3 | - Added `jvm` and `figure_windows` arguments. 4 | 5 | # CHANGES IN matlabr VERSION 1.5.2 6 | 7 | - Added single threaded mode in `run_matlab_script`. 8 | 9 | 10 | # CHANGES IN matlabr VERSION 1.5.0 11 | 12 | - Added Windows capabilities 13 | 14 | # CHANGES IN matlabr VERSION 1.4.3 15 | 16 | - Fixed https problem. 17 | 18 | # CHANGES IN matlabr VERSION 1.4.2 19 | 20 | - Changed ability to have `nodesktop` and `nodisplay` when running code. 21 | - Related to `spm12r` results report 22 | 23 | # CHANGES IN matlabr VERSION 1.1.2 24 | 25 | ## NEW FEATURES 26 | 27 | - Added `have_matlab` to have logical check for matlab 28 | 29 | # CHANGES IN matlabr VERSION 1.1 30 | 31 | ## NEW FEATURES 32 | 33 | - first version of matlab: it covers most simple implementations of MATLAB code 34 | 35 | ## MISC 36 | 37 | - in this NEWS file, #n means the issue number on GitHub, e.g. #142 is https://github.com/muschellij2/matlabr/issues/142 38 | -------------------------------------------------------------------------------- /R/add_path.R: -------------------------------------------------------------------------------- 1 | #' Create PATHs to add to MATLAB PATHs 2 | #' 3 | #' @param path path to add 4 | #' 5 | #' @return A character vector 6 | #' @examples 7 | #' add_path("~/") 8 | #' gen_path("~/") 9 | #' gen_path("~/") 10 | #' @export 11 | add_path = function(path) { 12 | path = sapply(path, function(x) { 13 | paste0("addpath('", path, "');") 14 | }) 15 | path = unname(unlist(path)) 16 | return(path) 17 | } 18 | 19 | #' @rdname add_path 20 | #' @export 21 | gen_path = function(path) { 22 | path = sapply(path, function(x) { 23 | paste0("genpath('", path, "');") 24 | }) 25 | path = unname(unlist(path)) 26 | return(path) 27 | } 28 | 29 | #' @rdname add_path 30 | #' @export 31 | add_gen_path = function(path) { 32 | path = gen_path(path) 33 | path = add_path(path) 34 | path = unname(path) 35 | return(path) 36 | } -------------------------------------------------------------------------------- /R/matlab_script.R: -------------------------------------------------------------------------------- 1 | #' @title Find matlab path 2 | #' 3 | #' @description This tries to find matlab's path using a system which 4 | #' command, and then, if not found, looks at \code{getOption("matlab.path")}. If not path is found, it fails. 5 | #' @param try_defaults (logical) If \code{matlab} is not found from 6 | #' \code{Sys.which}, and \code{matlab.path} not found, then try some 7 | #' default PATHs for Linux and OS X. 8 | #' @param desktop Should desktop be active for MATLAB? 9 | #' @param splash Should splash be active for MATLAB? 10 | #' @param display Should display be active for MATLAB? 11 | #' @param wait Should R wait for the command to finish. Both 12 | #' passed to \code{\link{system}} and adds the \code{-wait} flag. 13 | #' @param single_thread Should the flag \code{-singleCompThread} 14 | #' be executed to limit MATLAB to a single computational thread? 15 | #' @param jvm should JVM be be loaded? If \code{FALSE}, then 16 | #' \code{-nojvm} 17 | #' @param figure_windows should figure windows be enabled. If 18 | #' not, \code{-noFigureWindows} will be called 19 | #' @export 20 | #' @return Character of command for matlab 21 | #' @examples 22 | #' if (have_matlab()) { 23 | #' get_matlab() 24 | #' } 25 | get_matlab = function( 26 | try_defaults = TRUE, 27 | desktop = FALSE, 28 | splash = FALSE, 29 | display = FALSE, 30 | jvm = TRUE, 31 | figure_windows = TRUE, 32 | wait = TRUE, 33 | single_thread = FALSE){ 34 | # find.matlab <- system("which matlab", ignore.stdout=TRUE) 35 | mat = paste0( 36 | "matlab", 37 | ifelse( 38 | .Platform$OS.type %in% "windows", 39 | ".exe", 40 | "") 41 | ) 42 | find.matlab = as.numeric(Sys.which(mat) == "") 43 | myfunc = function(x, name) { 44 | x = as.logical(x) 45 | ifelse(x, "", paste0("-no", name)) 46 | } 47 | desktop = myfunc(desktop, "desktop") 48 | splash = myfunc(splash, "splash") 49 | display = myfunc(display, "display") 50 | jvm = ifelse(!jvm, "-nojvm", "") 51 | figure_windows = ifelse(!figure_windows, "-noFigureWindows", "") 52 | wait = ifelse( 53 | .Platform$OS.type %in% "windows", 54 | ifelse(wait, "-wait", ""), 55 | "") 56 | 57 | matcmd <- paste0(mat, " ", 58 | wait, " ", 59 | desktop, " ", 60 | splash, " ", 61 | jvm, " ", 62 | figure_windows, " ", 63 | ifelse(single_thread, "-singleCompThread ", ""), 64 | display, " -r ") 65 | 66 | if (find.matlab != 0) { 67 | mpath = getOption("matlab.path") 68 | 69 | #################################### 70 | # Trying defaults 71 | #################################### 72 | if (is.null(mpath)) { 73 | if (try_defaults) { 74 | this.year = as.numeric(format(Sys.Date(), "%Y")) 75 | years = seq(this.year + 1, this.year - 5, by = -1) 76 | mac_ends = c(outer(years, c("a", "b"), paste0)) 77 | def_paths = c( 78 | "/usr/local/bin", 79 | "/usr/bin", 80 | paste0("/Applications/MATLAB_R", mac_ends, ".app/bin"), 81 | paste0("C:/Program Files/MATLAB/R", mac_ends, "/bin"), 82 | paste0("D:/Program Files/MATLAB/R", mac_ends, "/bin") 83 | ) 84 | for (ipath in def_paths) { 85 | def_path = file.path(ipath, mat) 86 | if (file.exists(def_path)) { 87 | warning(paste0("Setting matlab.path to ", ipath)) 88 | options(matlab.path = ipath) 89 | mpath = ipath 90 | break; 91 | } # end def_path 92 | } # end loop 93 | } # end try_defaults 94 | } # end null mpath 95 | 96 | stopifnot(!is.null(mpath)) 97 | stopifnot(file.exists(mpath)) 98 | mpath = shQuote(mpath) 99 | matcmd <- file.path(mpath, matcmd) 100 | } 101 | return(matcmd) 102 | } 103 | 104 | #' @title Logical check if MATLAB is accessible 105 | #' 106 | #' @description Uses \code{\link{get_matlab}} to check if 107 | #' MATLAB's path accessible 108 | #' @export 109 | #' @return Logical \code{TRUE} is MATLAB is accessible, \code{FALSE} if not 110 | #' @examples 111 | #' have_matlab() 112 | have_matlab = function(){ 113 | x = suppressWarnings(try(get_matlab(), silent = TRUE)) 114 | return(!inherits(x, "try-error")) 115 | } 116 | 117 | 118 | 119 | #' @title Run matlab script 120 | #' 121 | #' @description This function runs a matlab script, and 122 | #' returns exit statuses 123 | #' @param fname Filename of matlab script (.m file) 124 | #' @param verbose print diagnostic messages 125 | #' @param ... Options passed to \code{\link{system}} 126 | #' @inheritParams get_matlab 127 | #' @export 128 | #' @return Exit status of matlab code 129 | run_matlab_script = function( 130 | fname, 131 | verbose = TRUE, 132 | desktop = FALSE, 133 | splash = FALSE, 134 | display = FALSE, 135 | jvm = TRUE, 136 | figure_windows = TRUE, 137 | wait = TRUE, 138 | single_thread = FALSE, 139 | ...){ 140 | stopifnot(file.exists(fname)) 141 | matcmd = get_matlab( 142 | desktop = desktop, 143 | splash = splash, 144 | display = display, 145 | wait = wait, 146 | jvm = jvm, 147 | figure_windows = figure_windows, 148 | single_thread = single_thread) 149 | cmd = paste0(' "', "try, run('", fname, "'); ", 150 | "catch err, disp(err.message); ", 151 | "exit(1); end; exit(0);", '"') 152 | cmd = paste0(matcmd, cmd) 153 | if (verbose) { 154 | message("Command run is:") 155 | message(cmd) 156 | } 157 | x <- system(cmd, wait = wait, ...) 158 | return(x) 159 | } 160 | 161 | 162 | #' @title Runs matlab code 163 | #' 164 | #' @description This function takes in matlab code, where 165 | #' the last line must end with a ;, and returns the exit 166 | #' status 167 | #' @param code Character vector of code. 168 | #' @param endlines Logical of whether the semicolon (;) should be 169 | #' pasted to each element of the vector. 170 | #' @param verbose Print out filename to run 171 | #' @param add_clear_all Add \code{clear all;} to the beginning of code 172 | #' @param paths_to_add Character vector of PATHs to add to the 173 | #' script using \code{\link{add_path}} 174 | #' @param ... Options passed to \code{\link{run_matlab_script}} 175 | #' @export 176 | #' @return Exit status of matlab code 177 | #' @examples 178 | #' if (have_matlab()){ 179 | #' run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), 180 | #' paths_to_add = "~/") 181 | #' } 182 | #' \dontrun{ 183 | #' if (have_matlab()){ 184 | #' system.time({ 185 | #' run_matlab_code(c("disp('The version of the matlab is:')", 186 | #' "disp(version)"), jvm = FALSE, 187 | #' figure_windows = FALSE) 188 | #' }) 189 | #' run_matlab_code("disp(version)") 190 | #' run_matlab_code("disp(version)", paths_to_add = "~/") 191 | #' run_matlab_code(c("x = 5", "disp(['The value of x is ', num2str(x)])")) 192 | #' } 193 | #' } 194 | run_matlab_code = function( 195 | code, endlines = TRUE, verbose = TRUE, 196 | add_clear_all = FALSE, 197 | paths_to_add = NULL, 198 | ...){ 199 | # matcmd = get_matlab() 200 | code = c(ifelse(add_clear_all, "clear all;", ""), 201 | paste0("cd('", getwd(), "');"), code) 202 | if (!is.null(paths_to_add)) { 203 | paths_to_add = add_path(paths_to_add) 204 | code = c(code, paths_to_add) 205 | } 206 | sep = ifelse(endlines, ";", " ") 207 | code = paste0(code, sep = sep, collapse = "\n") 208 | code = gsub(";;", ";", code) 209 | # cmd <- paste(' "try \n') 210 | # cmd <- paste(cmd, code) 211 | # cmd <- paste(cmd, "\n catch err \n disp(err.message); \n exit(1); \n") 212 | # cmd <- paste0(cmd, 'end; \n exit(0);"') 213 | # cmd = gsub("\n", ";", cmd) 214 | # cmd = paste0(matcmd, cmd) 215 | cmd = code 216 | fname = tempfile(fileext = ".m") 217 | cat(cmd, file = fname) 218 | if (verbose) { 219 | message(paste0("Script created: ", fname)) 220 | } 221 | x = run_matlab_script(fname, verbose = verbose, ...) 222 | return(x) 223 | } 224 | -------------------------------------------------------------------------------- /R/rmat_to_matlab_mat.R: -------------------------------------------------------------------------------- 1 | #' @title Convert R matrix to matlab matrix 2 | #' 3 | #' @description This function takes in an R matrix then turns it into 4 | #' a matrix in matlab 5 | #' @param x matrix of values 6 | #' @param matname Object in matlab to be assigned 7 | #' @param transpose Transpose the matrix 8 | #' @export 9 | #' @return Character scalar of matlab code 10 | rmat_to_matlab_mat = function(x, matname = NULL, transpose = FALSE){ 11 | x = as.matrix(x) 12 | x = apply(x, 1, paste, collapse = ", ") 13 | x = paste(x, collapse = "; ") 14 | x = paste0("[", x, "]", ifelse(transpose, "'", ""), ";") 15 | if (!is.null(matname)) x = paste0(matname, " = ", x) 16 | x 17 | } -------------------------------------------------------------------------------- /R/rvec_to_matlab.R: -------------------------------------------------------------------------------- 1 | #' @title Convert R vector to matlab cell mat 2 | #' 3 | #' @description This function takes in an R vector then turns it into 4 | #' a cell list 5 | #' @param x Character vector of values 6 | #' @param matname Object in matlab to be assigned 7 | #' @export 8 | #' @return Character scalar of matlab code 9 | rvec_to_matlabclist = function(x, matname = NULL){ 10 | x = paste0("{'", x, "'};") 11 | x = paste(x, collapse = " ") 12 | x = paste0('[', x, '];') 13 | if (!is.null(matname)) x = paste0(matname, " = ", x) 14 | x 15 | } 16 | 17 | 18 | 19 | #' @title Convert R vector to matlab cell mat 20 | #' 21 | #' @description This function takes in an R numeric and returns a 22 | #' status 23 | #' @param x Numeric vector of values 24 | #' @param row Create row vector instead of column vector 25 | #' @param sep separator to use to separate cells. Will override row 26 | #' argument 27 | #' @param matname Object in matlab to be assigned 28 | #' @export 29 | #' @return Character scalar of matlab code 30 | #' @import stringr 31 | rvec_to_matlab = function(x, row = FALSE, 32 | sep = NULL, 33 | matname = NULL){ 34 | if (is.null(sep)) { 35 | sep = ifelse(row, ",", ";") 36 | } 37 | x = paste0(x, sep) 38 | x = paste(x, collapse = " ") 39 | x = str_trim(x) 40 | x = gsub(paste0(sep, "$"), "", x) 41 | x = paste0("[", x, "];") 42 | if (!is.null(matname)) x = paste0(matname, " = ", x) 43 | x 44 | } 45 | -------------------------------------------------------------------------------- /R/rvec_to_matlabcell.R: -------------------------------------------------------------------------------- 1 | #' @title Convert R vector to matlab cell 2 | #' 3 | #' @description This function takes in an R vector then turns it into 4 | #' a cell 5 | #' @param x Character vector of values 6 | #' @param sep separator to use to separate values. Defaults to ";" 7 | #' argument 8 | #' @param matname Object in matlab to be assigned 9 | #' @param transpose Transpose the cell 10 | #' @export 11 | #' @return Character scalar of matlab code 12 | rvec_to_matlabcell = function(x, 13 | sep = ";", 14 | matname = NULL, 15 | transpose = FALSE){ 16 | x = paste0("'", x, "'", sep) 17 | x = paste(x, collapse = " ") 18 | x = paste0("{", x, "}", ifelse(transpose, "'", ""), sep) 19 | if (!is.null(matname)) x = paste0(matname, " = ", x) 20 | x 21 | } -------------------------------------------------------------------------------- /README.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | output: github_document 3 | --- 4 | 5 | [![Travis build status](https://travis-ci.org/muschellij2/matlabr.svg?branch=master)](https://travis-ci.org/muschellij2/matlabr) 6 | [![AppVeyor Build Status](https://ci.appveyor.com/api/projects/status/github/muschellij2/matlabr?branch=master&svg=true)](https://ci.appveyor.com/project/muschellij2/matlabr) 7 | [![Coverage status](https://coveralls.io/repos/github/muschellij2/matlabr/badge.svg?branch=master)](https://coveralls.io/r/muschellij2/matlabr?branch=master) 8 | [![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/matlabr)](https://cran.R-project.org/package=matlabr) 9 | [![Downloads](https://cranlogs.r-pkg.org/badges/matlabr)](https://cran.R-project.org/package=matlabr) 10 | 11 | 12 | 13 | ```{r setup, include = FALSE} 14 | knitr::opts_chunk$set( 15 | collapse = TRUE, 16 | comment = "#>", 17 | fig.path = "man/figures/README-" 18 | ) 19 | ``` 20 | # matlabr Package: 21 | 22 | `matlabr` is an R package to call MATLAB directly using `system` command. This is a simple package that tries to get around using `R.matlab` and a MATLAB server. 23 | 24 | ## Installation 25 | 26 | You can install the stable version on 27 | [CRAN](https://cran.R-project.org/package=matlabr): 28 | 29 | ```r 30 | install.packages('matlabr', dependencies = TRUE) 31 | ``` 32 | 33 | You can install `matlabr` from GitHub with: 34 | 35 | ```{r gh-installation, eval = FALSE} 36 | # install.packages("remotes") 37 | remotes::install_github("muschellij2/matlabr") 38 | ``` 39 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | [![Travis build 3 | status](https://travis-ci.org/muschellij2/matlabr.svg?branch=master)](https://travis-ci.org/muschellij2/matlabr) 4 | [![AppVeyor Build 5 | Status](https://ci.appveyor.com/api/projects/status/github/muschellij2/matlabr?branch=master&svg=true)](https://ci.appveyor.com/project/muschellij2/matlabr) 6 | [![Coverage 7 | status](https://coveralls.io/repos/github/muschellij2/matlabr/badge.svg?branch=master)](https://coveralls.io/r/muschellij2/matlabr?branch=master) 8 | [![CRAN\_Status\_Badge](https://www.r-pkg.org/badges/version/matlabr)](https://cran.R-project.org/package=matlabr) 9 | [![Downloads](https://cranlogs.r-pkg.org/badges/matlabr)](https://cran.R-project.org/package=matlabr) 10 | 11 | 12 | 13 | # matlabr Package: 14 | 15 | `matlabr` is an R package to call MATLAB directly using `system` 16 | command. This is a simple package that tries to get around using 17 | `R.matlab` and a MATLAB server. 18 | 19 | ## Installation 20 | 21 | You can install the stable version on 22 | [CRAN](https://cran.R-project.org/package=matlabr): 23 | 24 | ``` r 25 | install.packages('matlabr', dependencies = TRUE) 26 | ``` 27 | 28 | You can install `matlabr` from GitHub with: 29 | 30 | ``` r 31 | # install.packages("remotes") 32 | remotes::install_github("muschellij2/matlabr") 33 | ``` 34 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | init: 2 | ps: | 3 | $ErrorActionPreference = "Stop" 4 | Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "..\appveyor-tool.ps1" 5 | Import-Module '..\appveyor-tool.ps1' 6 | install: 7 | ps: Bootstrap 8 | cache: C:\RLibrary 9 | build_script: travis-tool.sh install_deps 10 | test_script: travis-tool.sh run_tests 11 | on_failure: 12 | - 7z a failure.zip *.Rcheck\* 13 | - appveyor PushArtifact failure.zip 14 | artifacts: 15 | - path: '*.Rcheck\**\*.log' 16 | name: Logs 17 | - path: '*.Rcheck\**\*.out' 18 | name: Logs 19 | - path: '*.Rcheck\**\*.fail' 20 | name: Logs 21 | - path: '*.Rcheck\**\*.Rout' 22 | name: Logs 23 | - path: \*_*.zip 24 | name: Bits 25 | environment: 26 | global: 27 | WARNINGS_ARE_ERRORS: 1.0 28 | USE_RTOOLS: yes 29 | R_CHECK_INSTALL_ARGS: --install-args=--build --no-multiarch 30 | deploy: 31 | provider: GitHub 32 | description: Windows Binary 33 | auth_token: 34 | secure: tc2Va9OWLH9H/uKPUKCUmv+q+wQpzRVJd6t8ckXjqzGnOo9eWyiQCmuuUjcuM3b8 35 | draft: no 36 | prerelease: no 37 | 'on': 38 | appveyor_repo_tag: true 39 | 40 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: false 2 | -------------------------------------------------------------------------------- /cran-comments.md: -------------------------------------------------------------------------------- 1 | ## Test environments 2 | * local R installation, R 4.0.0 3 | * ubuntu 16.04 (on travis-ci), R 4.0.0 4 | * win-builder (devel) 5 | 6 | ## R CMD check results 7 | 8 | 0 errors | 0 warnings | 1 note 9 | 10 | * This is a new release. 11 | -------------------------------------------------------------------------------- /man/add_path.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/add_path.R 3 | \name{add_path} 4 | \alias{add_path} 5 | \alias{gen_path} 6 | \alias{add_gen_path} 7 | \title{Create PATHs to add to MATLAB PATHs} 8 | \usage{ 9 | add_path(path) 10 | 11 | gen_path(path) 12 | 13 | add_gen_path(path) 14 | } 15 | \arguments{ 16 | \item{path}{path to add} 17 | } 18 | \value{ 19 | A character vector 20 | } 21 | \description{ 22 | Create PATHs to add to MATLAB PATHs 23 | } 24 | \examples{ 25 | add_path("~/") 26 | gen_path("~/") 27 | gen_path("~/") 28 | } 29 | -------------------------------------------------------------------------------- /man/get_matlab.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matlab_script.R 3 | \name{get_matlab} 4 | \alias{get_matlab} 5 | \title{Find matlab path} 6 | \usage{ 7 | get_matlab( 8 | try_defaults = TRUE, 9 | desktop = FALSE, 10 | splash = FALSE, 11 | display = FALSE, 12 | jvm = TRUE, 13 | figure_windows = TRUE, 14 | wait = TRUE, 15 | single_thread = FALSE 16 | ) 17 | } 18 | \arguments{ 19 | \item{try_defaults}{(logical) If \code{matlab} is not found from 20 | \code{Sys.which}, and \code{matlab.path} not found, then try some 21 | default PATHs for Linux and OS X.} 22 | 23 | \item{desktop}{Should desktop be active for MATLAB?} 24 | 25 | \item{splash}{Should splash be active for MATLAB?} 26 | 27 | \item{display}{Should display be active for MATLAB?} 28 | 29 | \item{jvm}{should JVM be be loaded? If \code{FALSE}, then 30 | \code{-nojvm}} 31 | 32 | \item{figure_windows}{should figure windows be enabled. If 33 | not, \code{-noFigureWindows} will be called} 34 | 35 | \item{wait}{Should R wait for the command to finish. Both 36 | passed to \code{\link{system}} and adds the \code{-wait} flag.} 37 | 38 | \item{single_thread}{Should the flag \code{-singleCompThread} 39 | be executed to limit MATLAB to a single computational thread?} 40 | } 41 | \value{ 42 | Character of command for matlab 43 | } 44 | \description{ 45 | This tries to find matlab's path using a system which 46 | command, and then, if not found, looks at \code{getOption("matlab.path")}. If not path is found, it fails. 47 | } 48 | \examples{ 49 | if (have_matlab()) { 50 | get_matlab() 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /man/have_matlab.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matlab_script.R 3 | \name{have_matlab} 4 | \alias{have_matlab} 5 | \title{Logical check if MATLAB is accessible} 6 | \usage{ 7 | have_matlab() 8 | } 9 | \value{ 10 | Logical \code{TRUE} is MATLAB is accessible, \code{FALSE} if not 11 | } 12 | \description{ 13 | Uses \code{\link{get_matlab}} to check if 14 | MATLAB's path accessible 15 | } 16 | \examples{ 17 | have_matlab() 18 | } 19 | -------------------------------------------------------------------------------- /man/rmat_to_matlab_mat.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rmat_to_matlab_mat.R 3 | \name{rmat_to_matlab_mat} 4 | \alias{rmat_to_matlab_mat} 5 | \title{Convert R matrix to matlab matrix} 6 | \usage{ 7 | rmat_to_matlab_mat(x, matname = NULL, transpose = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{matrix of values} 11 | 12 | \item{matname}{Object in matlab to be assigned} 13 | 14 | \item{transpose}{Transpose the matrix} 15 | } 16 | \value{ 17 | Character scalar of matlab code 18 | } 19 | \description{ 20 | This function takes in an R matrix then turns it into 21 | a matrix in matlab 22 | } 23 | -------------------------------------------------------------------------------- /man/run_matlab_code.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matlab_script.R 3 | \name{run_matlab_code} 4 | \alias{run_matlab_code} 5 | \title{Runs matlab code} 6 | \usage{ 7 | run_matlab_code( 8 | code, 9 | endlines = TRUE, 10 | verbose = TRUE, 11 | add_clear_all = FALSE, 12 | paths_to_add = NULL, 13 | ... 14 | ) 15 | } 16 | \arguments{ 17 | \item{code}{Character vector of code.} 18 | 19 | \item{endlines}{Logical of whether the semicolon (;) should be 20 | pasted to each element of the vector.} 21 | 22 | \item{verbose}{Print out filename to run} 23 | 24 | \item{add_clear_all}{Add \code{clear all;} to the beginning of code} 25 | 26 | \item{paths_to_add}{Character vector of PATHs to add to the 27 | script using \code{\link{add_path}}} 28 | 29 | \item{...}{Options passed to \code{\link{run_matlab_script}}} 30 | } 31 | \value{ 32 | Exit status of matlab code 33 | } 34 | \description{ 35 | This function takes in matlab code, where 36 | the last line must end with a ;, and returns the exit 37 | status 38 | } 39 | \examples{ 40 | if (have_matlab()){ 41 | run_matlab_code(c("disp('The version of the matlab is:')", "disp(version)"), 42 | paths_to_add = "~/") 43 | } 44 | \dontrun{ 45 | if (have_matlab()){ 46 | system.time({ 47 | run_matlab_code(c("disp('The version of the matlab is:')", 48 | "disp(version)"), jvm = FALSE, 49 | figure_windows = FALSE) 50 | }) 51 | run_matlab_code("disp(version)") 52 | run_matlab_code("disp(version)", paths_to_add = "~/") 53 | run_matlab_code(c("x = 5", "disp(['The value of x is ', num2str(x)])")) 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /man/run_matlab_script.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/matlab_script.R 3 | \name{run_matlab_script} 4 | \alias{run_matlab_script} 5 | \title{Run matlab script} 6 | \usage{ 7 | run_matlab_script( 8 | fname, 9 | verbose = TRUE, 10 | desktop = FALSE, 11 | splash = FALSE, 12 | display = FALSE, 13 | jvm = TRUE, 14 | figure_windows = TRUE, 15 | wait = TRUE, 16 | single_thread = FALSE, 17 | ... 18 | ) 19 | } 20 | \arguments{ 21 | \item{fname}{Filename of matlab script (.m file)} 22 | 23 | \item{verbose}{print diagnostic messages} 24 | 25 | \item{desktop}{Should desktop be active for MATLAB?} 26 | 27 | \item{splash}{Should splash be active for MATLAB?} 28 | 29 | \item{display}{Should display be active for MATLAB?} 30 | 31 | \item{jvm}{should JVM be be loaded? If \code{FALSE}, then 32 | \code{-nojvm}} 33 | 34 | \item{figure_windows}{should figure windows be enabled. If 35 | not, \code{-noFigureWindows} will be called} 36 | 37 | \item{wait}{Should R wait for the command to finish. Both 38 | passed to \code{\link{system}} and adds the \code{-wait} flag.} 39 | 40 | \item{single_thread}{Should the flag \code{-singleCompThread} 41 | be executed to limit MATLAB to a single computational thread?} 42 | 43 | \item{...}{Options passed to \code{\link{system}}} 44 | } 45 | \value{ 46 | Exit status of matlab code 47 | } 48 | \description{ 49 | This function runs a matlab script, and 50 | returns exit statuses 51 | } 52 | -------------------------------------------------------------------------------- /man/rvec_to_matlab.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rvec_to_matlab.R 3 | \name{rvec_to_matlab} 4 | \alias{rvec_to_matlab} 5 | \title{Convert R vector to matlab cell mat} 6 | \usage{ 7 | rvec_to_matlab(x, row = FALSE, sep = NULL, matname = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{Numeric vector of values} 11 | 12 | \item{row}{Create row vector instead of column vector} 13 | 14 | \item{sep}{separator to use to separate cells. Will override row 15 | argument} 16 | 17 | \item{matname}{Object in matlab to be assigned} 18 | } 19 | \value{ 20 | Character scalar of matlab code 21 | } 22 | \description{ 23 | This function takes in an R numeric and returns a 24 | status 25 | } 26 | -------------------------------------------------------------------------------- /man/rvec_to_matlabcell.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rvec_to_matlabcell.R 3 | \name{rvec_to_matlabcell} 4 | \alias{rvec_to_matlabcell} 5 | \title{Convert R vector to matlab cell} 6 | \usage{ 7 | rvec_to_matlabcell(x, sep = ";", matname = NULL, transpose = FALSE) 8 | } 9 | \arguments{ 10 | \item{x}{Character vector of values} 11 | 12 | \item{sep}{separator to use to separate values. Defaults to ";" 13 | argument} 14 | 15 | \item{matname}{Object in matlab to be assigned} 16 | 17 | \item{transpose}{Transpose the cell} 18 | } 19 | \value{ 20 | Character scalar of matlab code 21 | } 22 | \description{ 23 | This function takes in an R vector then turns it into 24 | a cell 25 | } 26 | -------------------------------------------------------------------------------- /man/rvec_to_matlabclist.Rd: -------------------------------------------------------------------------------- 1 | % Generated by roxygen2: do not edit by hand 2 | % Please edit documentation in R/rvec_to_matlab.R 3 | \name{rvec_to_matlabclist} 4 | \alias{rvec_to_matlabclist} 5 | \title{Convert R vector to matlab cell mat} 6 | \usage{ 7 | rvec_to_matlabclist(x, matname = NULL) 8 | } 9 | \arguments{ 10 | \item{x}{Character vector of values} 11 | 12 | \item{matname}{Object in matlab to be assigned} 13 | } 14 | \value{ 15 | Character scalar of matlab code 16 | } 17 | \description{ 18 | This function takes in an R vector then turns it into 19 | a cell list 20 | } 21 | -------------------------------------------------------------------------------- /matlabr.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: Default 4 | SaveWorkspace: Default 5 | AlwaysSaveHistory: Default 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: knitr 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Package 16 | PackageUseDevtools: Yes 17 | PackageInstallArgs: --no-multiarch --with-keep.source 18 | PackageCheckArgs: --as-cran 19 | PackageRoxygenize: rd,collate,namespace,vignette 20 | --------------------------------------------------------------------------------