Title: | Translation Layer from MATLAB to R |
---|---|
Description: | Allows users familiar with MATLAB to use MATLAB-named functions in R. Several basic MATLAB functions are written in this package to mimic the behavior of their original counterparts, with more to come as this package grows. |
Authors: | Waldir Leoncio [aut, cre] |
Maintainer: | Waldir Leoncio <[email protected]> |
License: | GPL (>= 3) |
Version: | 1.5.0.9000 |
Built: | 2024-11-04 04:49:15 UTC |
Source: | https://github.com/ocbe-uio/matlab2r |
Prints package version number and welcome message on package load
.onAttach(libname, pkgname)
.onAttach(libname, pkgname)
libname |
library location. See |
pkgname |
package name. See |
Throw error if condition false
assert(cond, msg = "Assertion failed.", A = NULL)
assert(cond, msg = "Assertion failed.", A = NULL)
cond |
Logical test |
msg |
Error message to be displayed if |
A |
values to format |
The error message if cond == FALSE
, nothing otherwise
Waldir Leoncio
minVal <- 7 x <- 26 assert(minVal < x) # should return nothing maxVal <- 13 ## Not run: assert((minVal < x) && (x < maxVal)) assert(x == "a", "x is %s", class(x)) ## End(Not run)
minVal <- 7 x <- 26 assert(minVal < x) # should return nothing maxVal <- 13 ## Not run: assert((minVal < x) && (x < maxVal)) assert(x == "a", "x is %s", class(x)) ## End(Not run)
Create character vector of blanks
blanks(n)
blanks(n)
n |
length of vector |
This function emulates the behavior of a homonimous function from Matlab
Vector of n blanks
Waldir Leoncio
blanks(1) blanks(3)
blanks(1) blanks(3)
Creates an array of zeros
cell(n, sz = c(n, n), expandable = FALSE, ...)
cell(n, sz = c(n, n), expandable = FALSE, ...)
n |
a the first dimension (or both, if sz is not passed) |
sz |
the second dimension (or 1st and 2nd, if not passed) |
expandable |
if TRUE, output is a list (so it can take different lengths) |
... |
Other dimensions |
An array of zeroes with the dimensions passed on call
cell(5) cell(5, 2)
cell(5) cell(5, 2)
A character array is a sequence of characters, just as a numeric array is a sequence of numbers. A typical use is to store a short piece of text as a row of characters in a character vector.
char(A) ## S4 method for signature 'character' char(A) ## S4 method for signature 'array' char(A)
char(A) ## S4 method for signature 'character' char(A) ## S4 method for signature 'array' char(A)
A |
a vector or array (not yet supported) |
A
converted to characters
char(character)
: Converting a character vector
char(array)
: Converting a character array
Waldir Leoncio
char("Hi!") char(matrix(letters, 2))
char("Hi!") char(matrix(letters, 2))
Simulates the function colon()
and its equivalent :
operator from Matlab, which have a similar but not quite equivalent behavior
when compared to seq()
and :
in R.
colon(a, b)
colon(a, b)
a |
initial number |
b |
final number |
A vector containing a sequence of integers going from a to b
colon(1, 4) colon(4, 8)
colon(1, 4) colon(4, 8)
disp(X)
displays the value of variable X
without printing the variable name. This is a wrapper around base::cat()
that includes a breakline in the end.
disp(X)
disp(X)
X |
variable |
The value of X
Waldir Leoncio
A <- c(15, 150) S <- 'Hello World.' disp(A) disp(S)
A <- c(15, 150) S <- 'Hello World.' disp(A) disp(S)
Emulates behavior of find
find(x, sort = TRUE)
find(x, sort = TRUE)
x |
object or logic operation on an object |
sort |
sort output? |
A vector of indices of x that satisfy the logical test (nonzero, by default).
X <- matrix(c(1, 0, 2, 0, 1, 1, 0, 0, 4), 3, byrow = TRUE) Y <- seq(1, 19, 2) find(X) find(Y == 13)
X <- matrix(c(1, 0, 2, 0, 1, 1, 0, 0, 4), 3, byrow = TRUE) Y <- seq(1, 19, 2) find(X) find(Y == 13)
Rounds each element of input to the nearest integer towards zero. Basically the same as trunc()
fix(X)
fix(X)
X |
input element |
The values of trunc(X)
.
Waldir Leoncio
X <- matrix(c(-1.9, -3.4, 1.6, 2.5, -4.5, 4.5), 3, byrow = TRUE) Y <- matrix(c(-1, -3, 1, 2, -4, 4), 3, byrow = TRUE) fix(X) fix(Y)
X <- matrix(c(-1.9, -3.4, 1.6, 2.5, -4.5, 4.5), 3, byrow = TRUE) Y <- matrix(c(-1, -3, 1, 2, -4, 4), 3, byrow = TRUE) fix(X) fix(Y)
Calculates the natural logarithm of the gamma function
gammaln(A)
gammaln(A)
A |
a non-negative, real matrix, vector or scalar |
An element-by-element ln(gamma())
-transformed A
For MATLAB output reproduction, non-positive values will be
Waldir Leoncio
gammaln(8) gammaln(0) gammaln(matrix(1:9, 3)) gammaln(-4:10)
gammaln(8) gammaln(0) gammaln(matrix(1:9, 3)) gammaln(-4:10)
Replicates the functionality of the homonymous function in Matlab (sans dialog box)
inputdlg(prompt, dims = 1, definput = NULL)
inputdlg(prompt, dims = 1, definput = NULL)
prompt |
Text field with user instructions |
dims |
number of dimensions in the answwers |
definput |
default value of the input |
A user prompt
## Not run: name <- inputdlg("Type your name") paste("Hello,", name) ## End(Not run)
## Not run: name <- inputdlg("Type your name") paste("Hello,", name) ## End(Not run)
Determine whether array is empty. An empty array, table, or timetable has at least one dimension with length 0, such as 0-by-0 or 0-by-5.
isempty(x)
isempty(x)
x |
array |
Emulates the behavior of the isempty
function on Matlab
A logical value determining if x is empty
isempty(array(dim = c(0, 2, 2))) isempty(matrix(rep(NA, 4), 2)) isempty(matrix(rep(0, 4), 2)) isempty(as.factor(c(NA, NA))) isempty(factor()) isempty(matrix(rep("", 3)))
isempty(array(dim = c(0, 2, 2))) isempty(matrix(rep(NA, 4), 2)) isempty(matrix(rep(0, 4), 2)) isempty(as.factor(c(NA, NA))) isempty(factor()) isempty(matrix(rep("", 3)))
This function tries to replicate the behavior of the isfield
function in Matlab
isfield(x, field)
isfield(x, field)
x |
list |
field |
name of field |
A logical vector determining if field
is within
names(x)
https://se.mathworks.com/help/matlab/ref/isfield.html
S <- list( x = rnorm(100), title = "x" ) isfield(S, "title") isfield(S, "z")
S <- list( x = rnorm(100), title = "x" ) isfield(S, "title") isfield(S, "z")
A simple check if an input corresponds to a valid path to a file
isFilePath(x)
isFilePath(x)
x |
input |
TRUE
if x
is a valid path, FALSE
otherwise
Waldir Leoncio
Checks which members of one entity are in another
ismember(A, B, rows = FALSE, indices = FALSE) ## S4 method for signature 'data.frame,data.frame' ismember(A, B, rows = FALSE, indices = FALSE)
ismember(A, B, rows = FALSE, indices = FALSE) ## S4 method for signature 'data.frame,data.frame' ismember(A, B, rows = FALSE, indices = FALSE)
A |
a vector, matrix or dataframe |
B |
another vector, matrix or dataframe |
rows |
if |
indices |
if |
a binary vector telling if the corresponding A indices are in B. If
indices = TRUE
, also prints the index in B where the match first
occurs.
Waldir Leoncio
# Values that are members of set A <- c(5, 3, 4, 2) B <- c(2, 4, 4, 4, 6, 8) ismember(A, B) # Members of set and indices to values ismember(A, B, indices = TRUE) # Table rows found in another table A <- data.frame( "V1" = 1:5, "V2" = LETTERS[1:5], "V3" = as.logical(c(0, 1, 0, 1, 0)) ) B <- data.frame( "V1" = seq(1, 9, 2), "V2" = LETTERS[seq(1, 9, 2)], "V3" = as.logical(rep(0, 5)) ) ismember(A, B)
# Values that are members of set A <- c(5, 3, 4, 2) B <- c(2, 4, 4, 4, 6, 8) ismember(A, B) # Members of set and indices to values ismember(A, B, indices = TRUE) # Table rows found in another table A <- data.frame( "V1" = 1:5, "V2" = LETTERS[1:5], "V3" = as.logical(c(0, 1, 0, 1, 0)) ) B <- data.frame( "V1" = seq(1, 9, 2), "V2" = LETTERS[seq(1, 9, 2)], "V3" = as.logical(rep(0, 5)) ) ismember(A, B)
Does the
ismembertol(A, B, rows = FALSE, indices = TRUE)
ismembertol(A, B, rows = FALSE, indices = TRUE)
A |
a vector, matrix or dataframe |
B |
another vector, matrix or dataframe |
rows |
if |
indices |
if |
Same as ismember
Waldir Leoncio
ismember
x <- t(1:6) * pi y <- 10 ^ log10(x) # Show that values are equal, but not identical (due to floating-point error) all.equal(x, y) identical(x, y) # Checking the difference in outputs ismember(x, y) ismembertol(x, y)
x <- t(1:6) * pi y <- 10 ^ log10(x) # Show that values are equal, but not identical (due to floating-point error) all.equal(x, y) identical(x, y) # Checking the difference in outputs ismember(x, y) ismembertol(x, y)
Determine which characters are space characters
isspace(A)
isspace(A)
A |
a character array or a string scalar |
a vector TF such that the elements of TF are logical 1 (true) where corresponding characters in A are space characters, and logical 0 (false) elsewhere.
Recognized whitespace characters are
and \\t
.
Waldir Leoncio
chr <- "123 Main St." X <- "\t a b\tcde f" isspace(chr) isspace(X)
chr <- "123 Main St." X <- "\t a b\tcde f" isspace(chr) isspace(X)
This is a soft wrap around the base::seq()
function.
linspace(x1, x2, n = 100L)
linspace(x1, x2, n = 100L)
x1 |
start point |
x2 |
end point |
n |
length of output |
A numeric vector of n
numbers between x1
and x2
.
Waldir Leoncio
linspace(-5, 4) linspace(1 + 2i, 9 + 9i, 5)
linspace(-5, 4) linspace(1 + 2i, 9 + 9i, 5)
Base 2 logarithm and floating-point number dissection
log2(X, dissect = TRUE)
log2(X, dissect = TRUE)
X |
a scalar or vector of numbers |
dissect |
if |
either a vector or a list of mantissas and exponents such that mantissa * 2 ^ exponent equals X
log2(10, dissect = FALSE) log2(10) .625 * 2 ^ 4 == 10 # proof
log2(10, dissect = FALSE) log2(10) .625 * 2 ^ 4 == 10 # proof
Performs basic syntax conversion from a Matlab function file to R
matlab2r( input, output = "diff", improve_formatting = TRUE, change_assignment = TRUE, append = FALSE, restyle = !improve_formatting, skip_lines = NULL )
matlab2r( input, output = "diff", improve_formatting = TRUE, change_assignment = TRUE, append = FALSE, restyle = !improve_formatting, skip_lines = NULL )
input |
file path or character string containing MATLAB code |
output |
can be "asis", "clean", "save" or "diff" |
improve_formatting |
if |
change_assignment |
if |
append |
if |
restyle |
if |
skip_lines |
vector of lines to be skipped. These will be commented out and tagged as TODO, instead. |
text converted to R, printed to screen or replacing input file
This function is intended to expedite the process of converting a Matlab function to R by making common replacements. It does not have the immediate goal of outputting a ready-to-use function. In other words, after using this function you should go back to it and make minor changes.
It is also advised to do a dry-run with output = "clean"
and only switching
to output = "save"
when you are confident that no important code will be
lost (for shorter functions, a careful visual inspection should suffice).
Waldir Leoncio
matlab_script <- system.file("extdata", "matlabDemo.m", package = "matlab2r") matlab2r(matlab_script) matlab2r(matlab_script, output = "clean")
matlab_script <- system.file("extdata", "matlabDemo.m", package = "matlab2r") matlab2r(matlab_script) matlab2r(matlab_script, output = "clean")
Finds the minimum value for each column of a matrix, potentially returning the indices instead
max(X, indices = TRUE)
max(X, indices = TRUE)
X |
matrix |
indices |
return indices? |
Either a list or a vector
Waldir Leoncio
A <- matrix(c(23, 42, 37, 15, 52)) max(A) base::max(A) # for comparison
A <- matrix(c(23, 42, 37, 15, 52)) max(A) base::max(A) # for comparison
Finds the minimum value for each column of a matrix, potentially returning the indices instead
min(X, indices = TRUE)
min(X, indices = TRUE)
X |
matrix |
indices |
return indices? |
Either a list or a vector
Waldir Leoncio
A <- matrix(c(23, 42, 37, 15, 52)) min(A) base::min(A) # for comparison
A <- matrix(c(23, 42, 37, 15, 52)) min(A) base::min(A) # for comparison
Returns the number of arguments passed to the parent function
nargin()
nargin()
An integer indicating how many input arguments a function received.
This function only makes sense inside another function
Waldir Leoncio
https://stackoverflow.com/q/64422780/1169233
f <- function(x, y, z) return(nargin()) f(pi) f(y = 6, z = 5) f(letters) f(letters, LETTERS, pi)
f <- function(x, y, z) return(nargin()) f(pi) f(y = 6, z = 5) f(letters) f(letters, LETTERS, pi)
Converts a numeric value to character. This is essentially a
wrapper over base::as.character()
.
num2str(A, format) ## S4 method for signature 'numeric,missing' num2str(A) ## S4 method for signature 'array,missing' num2str(A) ## S4 method for signature 'numeric,numeric' num2str(A, format) ## S4 method for signature 'array,numeric' num2str(A, format) ## S4 method for signature 'numeric,character' num2str(A, format) ## S4 method for signature 'array,character' num2str(A, format)
num2str(A, format) ## S4 method for signature 'numeric,missing' num2str(A) ## S4 method for signature 'array,missing' num2str(A) ## S4 method for signature 'numeric,numeric' num2str(A, format) ## S4 method for signature 'array,numeric' num2str(A, format) ## S4 method for signature 'numeric,character' num2str(A, format) ## S4 method for signature 'array,character' num2str(A, format)
A |
numeric object |
format |
either a number or a string (see |
A
, with its format possibly reshaped by format
num2str(A = numeric, format = missing)
: Converting a vector to character
num2str(A = array, format = missing)
: Converting an array to character
num2str(A = numeric, format = numeric)
: Rounding a vector, then converting to character
num2str(A = array, format = numeric)
: Rounding an arrray, then converting to character
num2str(A = numeric, format = character)
: Formatting a vector, then converting to character
num2str(A = array, format = character)
: Formatting an array, then converting to character
Waldir Leoncio
X <- rnorm(10) num2str(X) num2str(X, 2) A <- matrix(runif(4), 2) num2str(A) num2str(A, 3) num2str(pi * 10, "%e")
X <- rnorm(10) num2str(X) num2str(X, 2) A <- matrix(runif(4), 2) num2str(A) num2str(A, 3) num2str(pi * 10, "%e")
wrapper of zeros_or_ones()
that replicates the behavior of
the ones()
function on Matlab
ones(n1, n2 = n1, ...)
ones(n1, n2 = n1, ...)
n1 |
number of rows |
n2 |
number of columns |
... |
extra dimensions |
An n1-by-n2 matrix of ones
ones(3) ones(8, 1)
ones(3) ones(8, 1)
This function aims to loosely mimic the behavior of the questdlg function on Matlab
questdlg( quest, dlgtitle = "", btn = c("y", "n"), defbtn = "n", accepted_ans = c("y", "yes", "n", "no") )
questdlg( quest, dlgtitle = "", btn = c("y", "n"), defbtn = "n", accepted_ans = c("y", "yes", "n", "no") )
quest |
Question |
dlgtitle |
Title of question |
btn |
Vector of alternatives |
defbtn |
Scalar with the name of the default option |
accepted_ans |
Vector containing accepted answers |
Whatever is entered by the user after the prompt created by the function.
## Not run: ans <- questdlg("Do you want to continue?", "Continue?") if (tolower(substring(ans, 1, 1)) == "y") { message("You typed yes") } else { message("You didn't type yes") } ## End(Not run)
## Not run: ans <- questdlg("Do you want to continue?", "Continue?") if (tolower(substring(ans, 1, 1)) == "y") { message("You typed yes") } else { message("You didn't type yes") } ## End(Not run)
Imitates the behavior of rand()
on Matlab
rand(r = 1, c = 1)
rand(r = 1, c = 1)
r |
number of rows of output matrix |
c |
number of columns of output matrix |
matrix with random trials from a standard
uniform distribution.
rand() rand(3, 2)
rand() rand(3, 2)
Rreturns the remainder after division of a
by b
,
where a
is the dividend and b
is the divisor. This function is
often called the remainder operation. The rem
function follows the
convention that rem(a,0)
is NaN
.
rem(a, b)
rem(a, b)
a |
the dividend |
b |
the divisor |
The remainder
Waldir Leoncio
rem(23, 5) rem(1:5, 3) rem(c(-4, -1, 7, 9), 3) #FIXME rem(c(0, 3.5, 5.9, 6.2, 9, 4 * pi), 2 * pi)
rem(23, 5) rem(1:5, 3) rem(c(-4, -1, 7, 9), 3) #FIXME rem(c(0, 3.5, 5.9, 6.2, 9, 4 * pi), 2 * pi)
Repeats a matrix over n columns and rows
repmat(mx, n)
repmat(mx, n)
mx |
matrix |
n |
either a scalar with the number of replications in both rows and columns or a <= 3-length vector with individual repetitions. |
This function was created to replicate the behavior of a homonymous function on Matlab
matrix replicated over ncol(mx) * n
columns and nrow(mx) * n
rows
The Matlab implementation of this function accepts n
with length > 2.
It should also be noted that a concatenated vector in R, e.g. c(5, 2)
,
becomes a column vector when coerced to matrix, even though it may look like
a row vector at first glance. This is important to keep in mind when
considering the expected output of this function. Vectors in R make sense to
be seen as column vectors, given R's Statistics-oriented paradigm where
variables are usually disposed as columns in a dataset.
x <- matrix(1:4, 2) repmat(x, 1) repmat(x, 2) repmat(x, c(2, 3))
x <- matrix(1:4, 2) repmat(x, 1) repmat(x, 2) repmat(x, c(2, 3))
Reshapes a matrix according to a certain number of dimensions
reshape(A, sz)
reshape(A, sz)
A |
input matrix |
sz |
vector containing the dimensions of the output vector |
This function replicates the functionality of the reshape()
function on Matlab. This function is basically a fancy wrapper for the
array()
function in R, but is useful because it saves the user translation
time. Moreover, it introduces validation code that alter the behavior of
array()
and makes it more similar to replicate()
.
the input matrix, reshaped according to the vector sz
The Matlab function also accepts as input the dismemberment of sz as scalars.
mx <- matrix(1:4, 2) ra <- array(1:12, c(2, 3, 2)) mx reshape(mx, c(1, 4)) ra reshape(ra, c(3, 2, 2))
mx <- matrix(1:4, 2) ra <- array(1:12, c(2, 3, 2)) mx reshape(mx, c(1, 4)) ra reshape(ra, c(3, 2, 2))
Loosely replicates the behavior of the homonym Matlab function
setdiff(A, B, legacy = FALSE)
setdiff(A, B, legacy = FALSE)
A |
first array |
B |
second array |
legacy |
if |
An array containing he elements which are in A but not in B
Waldir Leoncio
A <- c(3, 6, 2, 1, 5, 1, 1) B <- c(2, 4, 6) setdiff(A, B)
A <- c(3, 6, 2, 1, 5, 1, 1) B <- c(2, 4, 6) setdiff(A, B)
This functions tries to replicate the behavior of the base function "size" in Matlab
size(x, d)
size(x, d)
x |
object to be evaluated |
d |
dimension of object to be evaluated |
A vector whose size is the number of dimensions of x and whose scale corresponds to the number of elements on (i.e. the size of) each dimension.
On MATLAB, size(1, 100) returns 1. As a matter of fact, if the user
calls for a dimension which x doesn't have size()
always returns 1. R's
default behavior is more reasonable in those cases (i.e., returning NA),
but since the point of this function is to replicate MATLAB behaviors
(bugs and questionable behaviors included), this function also does this.
size(10) size(1:4) size(matrix(1:6, 2)) size(array(1:24, c(2, 3, 4)))
size(10) size(1:4) size(matrix(1:6, 2)) size(array(1:24, c(2, 3, 4)))
Emulates the behavior of the sortrows
function on Matlab
sortrows(A, column = 1)
sortrows(A, column = 1)
A |
matrix |
column |
ordering column |
The A matrix sorted by the first row, then the second
mx <- matrix(c(3, 2, 2, 1, 1, 10, 0, pi), 4) mx sortrows(mx)
mx <- matrix(c(3, 2, 2, 1, 1, 10, 0, pi), 4) mx sortrows(mx)
Remove dimensions of length 1
squeeze(A)
squeeze(A)
A |
input or array matrix |
This function implements the behavior of the homonimous function on
Matlab. B = squeeze(A)
returns an array with the same elements as the
input array A, but with dimensions of length 1 removed. For example, if A is
a 3-by-1-by-1-by-2 array, then squeeze(A) returns a 3-by-2 matrix. If A is a
row vector, column vector, scalar, or an array with no dimensions of length
1, then squeeze returns the input A.
An array with the same elements as the input array, but with dimensions of length 1 removed.
This is basically a wrapper of drop() with a minor adjustment to adapt the output to what happens on Matlab
Waldir Leoncio
A <- array(dim = c(2, 1, 2)) A[, , 1] <- c(1, 2) A[, , 2] <- c(3, 4) print(A) squeeze(A)
A <- array(dim = c(2, 1, 2)) A[, , 1] <- c(1, 2) A[, , 2] <- c(3, 4) print(A) squeeze(A)
Logical test if two character elements are identical
strcmp(s1, s2)
strcmp(s1, s2)
s1 |
first character element (string, vector or matrix) |
s2 |
second character element (string, vector or matrix) |
a logical element of the same type as the input
strcmp("yes", "no") strcmp("yes", "yes") strcmp("no", "no")
strcmp("yes", "no") strcmp("yes", "yes") strcmp("no", "no")
Returns the sum of the elements of the first input
sum_MATLAB(A, dim) ## S4 method for signature 'array,missing' sum_MATLAB(A) ## S4 method for signature 'array,character' sum_MATLAB(A, dim) ## S4 method for signature 'array,numeric' sum_MATLAB(A, dim)
sum_MATLAB(A, dim) ## S4 method for signature 'array,missing' sum_MATLAB(A) ## S4 method for signature 'array,character' sum_MATLAB(A, dim) ## S4 method for signature 'array,numeric' sum_MATLAB(A, dim)
A |
vector, matrix or array |
dim |
dimention over which A is to be summed |
The total, row or column sum of A
sum_MATLAB(A = array, dim = missing)
: Sum elements of A along the first array dimension
whose size does not equal 1
sum_MATLAB(A = array, dim = character)
: Computes the sum of all elements of A
sum_MATLAB(A = array, dim = numeric)
: Computes the sum of all elements of A
Waldir Leoncio
x1 <- array(1:9, c(3, 3)) sum_MATLAB(x1) sum_MATLAB(x1, "all") sum_MATLAB(x1, 2)
x1 <- array(1:9, c(3, 3)) sum_MATLAB(x1) sum_MATLAB(x1, "all") sum_MATLAB(x1, 2)
Emulates the times()
and .*
operators from Matlab.
times(a, b)
times(a, b)
a |
first factor of the multiplication |
b |
second factor of the multiplication |
This function basically handles elements of different length
better than the *
operator in R, at least as far as behavior from a
Matlab user is expecting.
matrix with dimensions equal to the larger of the two factors
times(9, 6) x <- matrix(1:4, 2) y <- c(10, 3) print(x) print(y) times(x, y) x * y
times(9, 6) x <- matrix(1:4, 2) y <- c(10, 3) print(x) print(y) times(x, y) x * y
Loosely mimics the functionality of the uigetfile
function on
Matlab.
uigetfile(filter = "", title = "")
uigetfile(filter = "", title = "")
filter |
Filter listed files |
title |
Pre-prompt message |
A list containing the name of the file selected and its path
https://se.mathworks.com/help/matlab/ref/uigetfile.html
## Not run: uigetfile() ## End(Not run)
## Not run: uigetfile() ## End(Not run)
This function intends to loosely mimic the behaviour of the homonymous Matlab function.
uiputfile(filter = ".rda", title = "Save file")
uiputfile(filter = ".rda", title = "Save file")
filter |
accepted file extension |
title |
Title |
A list containing the name and the path of the file to be saved
## Not run: uigetfile() ## End(Not run)
## Not run: uigetfile() ## End(Not run)
wrapper of zeros_or_ones()
that replicates the behavior of
the zeros()
function on Matlab
zeros(n1, n2 = n1, ...)
zeros(n1, n2 = n1, ...)
n1 |
number of rows |
n2 |
number of columns |
... |
extra dimensions |
An n1-by-n2 matrix of zeros
zeros(5) zeros(5, 3)
zeros(5) zeros(5, 3)
Generates a square or rectangular matrix of zeros or ones
zeros_or_ones(n, x)
zeros_or_ones(n, x)
n |
scalar or 2D vector |
x |
value to fill matrix with |
This is a wrapper function to replicate the behavior of the
zeros()
and the ones()
functions on Matlab
n-by-n matrix filled with x
Actually works for any x
, but there's no need to bother imposing
validation controls here.