Julia for MATLAB Users/Core Language/Language Fundamentals
Language Fundamentals edit
This page maps MATLAB functionality documented in the Language Fundamentals section of the MATLAB documentation to equivalent Julia (core language and/or package) functionality.
Another helpful resource is the noteworthy differences from MATLAB section of the Julia documentation.
Entering Commands edit
Related: Julia REPL
ans
Most recent answer
edit
Julia's ans
is functionally basically identical, though note that it is available only at the REPL.
clc
Clear Command Window
edit
Ctrl+L is nearly equivalent in the Julia REPL, though it does not erase history; you can still scroll up to see the history of the session. You can also equivalently (on Linux/Mac) run the clear(1)
command in shell mode, i.e. ;+clear.
save
Command Window text to file
edit
There doesn't appear to be an equivalent Julia REPL command.
format
Set Command Window output display format
edit
There is no drop-in equivalent in the Julia REPL or IJulia for globally setting the output format.
home
Send cursor home
edit
Ctrl+L is functionally equivalent in the Julia REPL.
iskeyword
Determine whether input is MATLAB keyword
edit
There doesn't appear to be an equivalent Julia command, but see Keywords in the Julia manual.
more
Control paged output for Command Window
edit
Matrices and Arrays edit
See Multi-dimensional Arrays in the Julia Manual.
zeros
Create array of all zeros; ones
Create array of all ones
edit
Julia's zeros
and ones
are functionally equivalent. Note that the syntax for specifying the data type of the result is different, e.g. Julia: zeros(Int64, 3, 3)
vs. MATLAB zeros(3,3, 'int64')
.
rand
Uniformly distributed random numbers
edit
See Julia's rand
.
true
Logical 1 (true); false
Logical 0 (false)
edit
eye
Identity matrix
edit
In Julia to construct a numeric identity matrix, use something like Matrix(1.0I, 3, 3)
. Note that the symbol I
is special in Julia; rather than representing a matrix, it is an instance of the UniformScaling
operator so that in principle its use can be more efficient than the naive use of a dense matrix that happens to have 1's on the diagonal and zeros elsewhere.
diag
Create diagonal matrix or get diagonal elements of matrix
edit
blkdiag
Construct block diagonal matrix from input arguments
edit
cat
Concatenate arrays along specified dimension
edit
horzcat
Concatenate arrays horizontally
edit
See Julia's hcat function
vertcat
Concatenate arrays vertically
edit
repelem
Repeat copies of array elements
edit
repmat
Repeat copies of array
edit
linspace
Generate linearly spaced vector
edit
logspace
Generate logarithmically spaced vector
edit
freqspace
Frequency spacing for frequency response
edit
meshgrid
2-D and 3-D grids
edit
ndgrid
Rectangular grid in N-D space
edit
length
Length of largest array dimension
edit
Julia has a length
function, however it does not operate the same way as Matlab's for multidimensional arrays. To get equivalent behavior to Matlab's length(X)
, use maximum(size(X))
in Julia.
size
Array size
edit
ndims
Number of array dimensions
edit
In Julia, ndims
is similar but not identical. For instance, Julia does not ignore singleton dimensions.
numel
Number of array elements
edit
In Julia, length
is equivalent.
isscalar
Determine whether input is scalar
edit
isvector
Determine whether input is vector
edit
ismatrix
Determine whether input is matrix
edit
isrow
Determine whether input is row vector
edit
iscolumn
Determine whether input is column vector
edit
isempty
Determine whether array is empty
edit
sort
Sort array elements
edit
sortrows
Sort rows of matrix or table
edit
issorted
Determine if array is sorted
edit
issortedrows
Determine if matrix or table rows are sorted
edit
topkrows
Top rows in sorted order
edit
flip
Flip order of elements
edit
fliplr
Flip array left to right
edit
flipud
Flip array up to down
edit
rot90
Rotate array 90 degrees
edit
transpose
Transpose vector or matrix
edit
ctranspose
Complex conjugate transpose
edit
permute
Rearrange dimensions of N-D array
edit
ipermute
Inverse permute dimensions of N-D array
edit
circshift
Shift array circularly
edit
shiftdim
Shift dimensions
edit
reshape
Reshape array
edit
squeeze
Remove singleton dimensions
edit
Julia's dropdims
function is similar though it requires the singleton dimension(s) to be specified explicitly.
colon
Vector creation, array subscripting, and for-loop iteration
edit
end
Terminate block of code, or indicate last array index
edit
Julia's end
is basically equivalent.
ind2sub
Subscripts from linear index
edit
sub2ind
Convert subscripts to linear indices
edit
Operators and Elementary Operations edit
See Mathematical Operations and Elementary Functions in the Julia manual.
Arithmetic edit
plus
Addition
edit
uplus
Unary plus
edit
minus
Subtraction
edit
uminus
Unary minus
edit
times
Element-wise multiplication
edit
rdivide
Right array division
edit
ldivide
Left array division
edit
power
Element-wise power
edit
mtimes
Matrix Multiplication
edit
mrdivide
Solve systems of linear equations xA = B for x
edit
mldivide
Solve systems of linear equations Ax = B for x
edit
mpower
Matrix power
edit
cumprod
Cumulative product
edit
cumsum
Cumulative sum
edit
diff
Differences and Approximate Derivatives
edit
movsum
Moving sum
edit
prod
Product of array elements
edit
sum
Sum of array elements
edit
ceil
Round toward positive infinity
edit
fix
Round toward zero
edit
floor
Round toward negative infinity
edit
idivide
Integer division with rounding option
edit
mod
Remainder after division (modulo operation)
edit
rem
Remainder after division
edit
round
Round to nearest decimal or integer
edit
bsxfun
Apply element-wise operation to two arrays with implicit expansion enabled
edit
Relational Operations edit
eq
Determine equality
edit
ge
Determine greater than or equal to
edit
gt
Determine greater than
edit
le
Determine less than or equal to
edit
lt
Determine less than
edit
ne
Determine inequality
edit
isequal
Determine array equality
edit
isequaln
Determine array equality, treating NaN values as equal
edit
Logical Operations edit
Logical Operators: Short-circuit Logical operations with short-circuiting edit
and
Find logical AND
edit
not
Find logical NOT
edit
or
Find logical OR
edit
xor
Find logical exclusive-OR
edit
all
Determine if all array elements are nonzero or true
edit
any
Determine if any array elements are nonzero
edit
false
Logical 0 (false)
edit
find
Find indices and values of nonzero elements
edit
In Julia, findall
provides similar functionality. See also findfirst
, findlast
, findnext
and findprev
.
islogical
Determine if input is logical array
edit
logical
Convert numeric values to logicals
edit
true
Logical 1 (true)
edit
Set Operations edit
intersect
Set intersection of two arrays
edit
ismember
Array elements that are members of set array
edit
ismembertol
Members of set within tolerance
edit
issorted
Determine if array is sorted
edit
setdiff
Set difference of two arrays
edit
setxor
Set exclusive OR of two arrays
edit
union
Set union of two arrays
edit
unique
Unique values in array
edit
uniquetol
Unique values within tolerance
edit
join
Combine two tables or timetables by rows using key variables
edit
innerjoin
Inner join between two tables or timetables
edit
outerjoin
Outer join between two tables or timetables
edit
Bit-Wise Operations edit
bitand
Bit-wise AND
edit
bitcmp
Bit-wise complement
edit
bitget
Get bit at specified position
edit
bitor
Bit-wise OR
edit
bitset
Set bit at specific location
edit
bitshift
Shift bits specified number of places
edit
bitxor
Bit-wise XOR
edit
swapbytes
Swap byte ordering
edit
Data Types edit
See Types in the Julia manual.