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.

Numeric Types

edit

double Double-precision arrays

edit

single Single-precision arrays

edit

int8 8-bit signed integer arrays

edit

int16 16-bit signed integer arrays

edit

int32 32-bit signed integer arrays

edit

int64 64-bit signed integer arrays

edit

uint8 8-bit unsigned integer arrays

edit

uint16 16-bit unsigned integer arrays

edit

uint32 32-bit unsigned integer arrays

edit

uint64 64-bit unsigned integer arrays

edit

cast Cast variable to different data type

edit

typecast Convert data types without changing underlying data

edit

isinteger Determine if input is integer array

edit

isfloat Determine if input is floating-point array

edit

isnumeric Determine if input is numeric array

edit

isreal Determine whether array is real

edit

isfinite Array elements that are finite

edit

isinf Array elements that are infinite

edit

isnan Array elements that are NaN

edit

eps Floating-point relative accuracy

edit

flintmax Largest consecutive integer in floating-point format

edit

Inf Infinity

edit

intmax Largest value of specified integer type

edit

intmin Smallest value of specified integer type

edit

NaN Not-a-Number

edit

realmax Largest positive floating-point number

edit

realmin Smallest positive normalized floating-point number

edit

Characters and Strings

edit

string String array

edit

strings Create array of strings with no characters

edit

join Combine strings

edit

char Character array

edit

cellstr Convert to cell array of character vectors

edit

blanks Create character array of blanks

edit

newline Create newline character

edit

compose Convert data into formatted string array

edit

sprintf Format data into string

edit

strcat Concatenate strings horizontally

edit

cOnverTcHarstostrings Convert character arrays to string arrays, leaving other arrays unaltered

edit

cOnvertsTrIngstoChars Convert string arrays to character arrays, leaving other arrays unaltered

edit

ischar Determine if input is character array

edit

iscellstr Determine if input is cell array of character vectors

edit

isstring Determine if input is string array

edit

isStringScalar Determine if input is string array with one element

edit

strlength Length of strings in string array

edit

isstrprop Determine if string is of specified category

edit

isletter Determine which characters are letters

edit

isspace Determine which characters are space characters

edit

contains Determine if pattern is in string

edit

count Count occurrences of pattern in string

edit

endsWith Determine if string ends with pattern

edit

StartsWith Determine if string starts with pattern

edit

strfind Find one string within another

edit

sscanf Read formatted data from string

edit

replace Find and replace substrings in string array

edit

rEplacebetween Replace substrings identified by indicators that mark their starts and ends

edit

strrep Find and replace substring

edit

join Combine strings

edit

split Split strings in string array

edit

splitlines Split string at newline characters

edit

strjoin Join text in array

edit

strsplit Split string at specified delimiter

edit

strtok Selected parts of string

edit

erase Delete substrings within strings

edit

erasebetween Delete substrings between indicators that mark starts and ends of substrings

edit

eXtractAfter Extract substring after specified position

edit

eXtractBefore Extract substring before specified position

edit

eXtractbetween Extract substrings between indicators that mark starts and ends of substrings

edit

InsertAfter Insert string after specified substring

edit

InsertBefore Insert string before specified substring

edit

pad Add leading or trailing characters to strings

edit

strip Remove leading and trailing characters from string

edit

lower Convert string to lowercase

edit

upper Convert string to uppercase

edit

reverse Reverse order of characters in string

edit

deblank Remove trailing whitespace from end of string or character array

edit

strtrim Remove leading and trailing whitespace from string array or character array

edit

strjust Justify string or character array

edit

strcmp Compare strings

edit

strcmpi Compare strings (case insensitive)

edit

strncmp Compare first n characters of strings (case sensitive)

edit

strncmpi Compare first n characters of strings (case insensitive)

edit

regexp Match regular expression (case sensitive)

edit

regexpi Match regular expression (case insensitive)

edit

regexprep Replace text using regular expression

edit

regexptranslate Translate text into regular expression

edit

Dates and Time

edit

datetime Arrays that represent points in time

edit

NaT Not-a-Time

edit

years Duration in years

edit

days Duration in days

edit

hours Duration in hours

edit

minutes Duration in minutes

edit

seconds Duration in seconds

edit

milliseconds Duration in milliseconds

edit

duration Lengths of time in fixed-length units

edit

calyears Calendar duration in years

edit

calquarters Calendar duration in quarters

edit

calmonths Calendar duration in months

edit

calweeks Calendar duration in weeks

edit

caldays Calendar duration in days

edit

caLendarduration Lengths of time in variable-length calendar units

edit

year Year number

edit

quarter Quarter number

edit

month Month number and name

edit

week Week number

edit

day Day number or name

edit

hour Hour number

edit

minute Minute number

edit

second Second number

edit

ymd Year, month, and day numbers of datetime

edit

hms Hour, minute, and second numbers of duration

edit

split Split calendar duration into numeric and duration units

edit

time Convert time of calendar duration to duration

edit

timeofday Elapsed time since midnight for datetimes

edit

isdatetime Determine if input is datetime array

edit

isduration Determine if input is duration array

edit

iscalendarduration Determine if input is calendar duration array

edit

isnat Determine NaT (Not-a-Time) elements

edit

isdst Determine daylight saving time elements

edit

isweekend Determine weekend elements

edit

timezones List time zones

edit

tzoffset Time zone offset from UTC

edit

between Calendar math differences

edit

caldiff Calendar math successive differences

edit

dateshift Shift date or generate sequence of dates and time

edit

isbetween Determine elements within date and time interval

edit

datenum Convert date and time to serial date number

edit

datevec Convert date and time to vector of components

edit

exceltime Convert MATLAB datetime to Excel date number

edit

juliandate Convert MATLAB datetime to Julian date

edit

posixtime Convert MATLAB datetime to POSIX time

edit

yyyymmdd Convert MATLAB datetime to YYYYMMDD numeric value

edit

addtodate Modify date number by field

edit

char Character array

edit

string String array

edit

datestr Convert date and time to string format

edit

now Current date and time as serial date number

edit

clock Current date and time as date vector

edit

date Current date string

edit

calendar Calendar for specified month

edit

eomday Last day of month

edit

weekday Day of week

edit

etime Time elapsed between date vectors

edit

Categorical Arrays

edit

categorical Array that contains values assigned to categories

edit

iscategorical Determine whether input is categorical array

edit

discretize Group data into bins or categories

edit

categories Categories of categorical array

edit

iscategory Test for categorical array categories

edit

isordinal Determine whether input is ordinal categorical array

edit

isprotected Determine whether categories of categorical array are protected

edit

addcats Add categories to categorical array

edit

mergecats Merge categories in categorical array

edit

removecats Remove categories from categorical array

edit

renamecats Rename categories in categorical array

edit

reordercats Reorder categories in categorical array

edit

setcats Set categories in categorical array

edit

summary Print summary of table, timetable, or categorical array

edit

countcats Count occurrences of categorical array elements by category

edit

isundefined Find undefined elements in categorical array

edit

Tables

edit

table Table array with named variables that can contain different types

edit

array2table Convert homogeneous array to table

edit

cell2table Convert cell array to table

edit

struct2table Convert structure array to table

edit

table2array Convert table to homogeneous array

edit

table2cell Convert table to cell array

edit

table2struct Convert table to structure array

edit

table2timetable Convert table to timetable

edit

timetable2table Convert timetable to table

edit

readtable Create table from file

edit

writetable Write table to file

edit

DetectImportoptions Create import options based on file content

edit

getvaropts Get variable import options

edit

setvaropts Set variable import options

edit

setvartype Set variable data types

edit

head Get top rows of table, timetable, or tall array

edit

tail Get bottom rows of table, timetable, or tall array

edit

summary Print summary of table, timetable, or categorical array

edit

height Number of table rows

edit

width Number of table variables

edit

istable Determine whether input is table

edit

sortrows Sort rows of matrix or table

edit

unique Unique values in array

edit

issortedrows Determine if matrix or table rows are sorted

edit

topkrows Top rows in sorted order

edit

addvars Add variables to table or timetable

edit

movevars Move variables in table or timetable

edit

removevars Delete variables from table or timetable

edit

splitvars Split multicolumn variables in table or timetable

edit

mergevars Combine table or timetable variables into multicolumn variable

edit

vartype Subscript into table or timetable by variable type

edit

rows2vars Reorient table or timetable so that rows become variables

edit

stack Stack data from multiple variables into single variable

edit

unstack Unstack data from single variable into multiple variables

edit

inner2outer Invert nested table-in-table hierarchy in tables or timetables

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

union Set union of two arrays

edit

intersect Set intersection of two arrays

edit

ismember Array elements that are members of set array

edit

setdiff Set difference of two arrays

edit

setxor Set exclusive OR of two arrays

edit

ismissing Find missing values

edit

standArdizemissing Insert standard missing values

edit

rmmissing Remove missing entries

edit

fillmissing Fill missing values

edit

varfun Apply function to table or timetable variables

edit

rowfun Apply function to table or timetable rows

edit

findgroups Find groups and return group numbers

edit

splitapply Split data into groups and apply function

edit

groupsummary Group summary computations

edit

Timetables

edit

timetable Timetable array with time-stamped rows and variables of different types

edit

retime resample or aggregate data in timetable, and resolve duplicate or irregular times

edit

synchronize synchronize timetables to common time vector, and resample or aggregate data from input timetables

edit

lag Time-shift data in timetable

edit

table2timetable Convert table to timetable

edit

array2timetable Convert homogeneous array to timetable

edit

timetable2table Convert timetable to table

edit

istimetable Determine if input is timetable

edit

isregular Determine whether times in timetable are regular

edit

timerange Time range for timetable row subscripting

edit

withtol Time tolerance for timetable row subscripting

edit

vartype Subscript into table or timetable by variable type

edit

rmmissing Remove missing entries

edit

issorted Determine if array is sorted

edit

sortrows Sort rows of matrix or table

edit

unique Unique values in array

edit

Structures

edit

struct Structure array

edit

fieldnames Field names of structure, or public fields of COM or Java object

edit

getfield Field of structure array

edit

isfield Determine whether input is structure array field

edit

isstruct Determine whether input is structure array

edit

orderfields Order fields of structure array

edit

rmfield Remove fields from structure

edit

setfield Assign values to structure array field

edit

arrayfun Apply function to each element of array

edit

structfun Apply function to each field of scalar structure

edit

table2struct Convert table to structure array

edit

struct2table Convert structure array to table

edit

cell2struct Convert cell array to structure array

edit

struct2cell Convert structure to cell array

edit

Cell Arrays

edit

cell Cell array

edit

cell2mat Convert cell array to ordinary array of the underlying data type

edit

cell2struct Convert cell array to structure array

edit

cell2table Convert cell array to table

edit

celldisp Display cell array contents

edit

cellfun Apply function to each cell in cell array

edit

cellplot Graphically display structure of cell array

edit

cellstr Convert to cell array of character vectors

edit

iscell Determine whether input is cell array

edit

iscellstr Determine if input is cell array of character vectors

edit

mat2cell Convert array to cell array with potentially different sized cells

edit

num2cell Convert array to cell array with consistently sized cells

edit

strjoin Join text in array

edit

strsplit Split string at specified delimiter

edit

struct2cell Convert structure to cell array

edit

table2cell Convert table to cell array

edit

Function Handles

edit

feval Evaluate function

edit

func2str Construct character vector from function handle

edit

str2func Construct function handle from character vector

edit

localfunctions Function handles to all local functions in MATLAB file

edit

functions Information about function handle

edit

Map Containers

edit

containers.Map Object that maps values to unique keys

edit

isKey Determine if Map object contains key

edit

keys Return keys of Map object

edit

remove Delete key-value pairs from Map object

edit

values Return values of Map object

edit

Time Series

edit

Time Series Objects

edit
timeseries Create timeseries object
edit
addevent Add event to timeseries
edit
addsample Add data sample to timeseries object
edit
append Concatenate timeseries objects in time
edit
delevent Remove event from timeseries
edit
delsample Remove sample from timeseries object
edit
detrend Subtract mean or best-fit line from timeseries object
edit
filter Modify frequency content of timeseries objects
edit
idealfilter timeseries ideal filter
edit
plot Plot timeseries
edit
resample Resample timeseries time vector
edit
set Set timeseries properties
edit
setabstime Set timeseries times as date character vectors
edit
setinterpfunction Set default interpolation method for timeseries object
edit
setuniformtime Modify uniform timeseries time vector
edit
synchronize Synchronize and resample two timeseries objects using common time vector
edit
get Query timeseries properties
edit
getabstime Convert timeseries time vector to cell array
edit
getdatasamples Access timeseries data samples
edit
getdatasamplesize timeseries data sample size
edit
getinterpmethod timeseries interpolation method
edit
getqualitydesc timeseries data quality
edit
getsamples Subset of timeseries
edit
getsampleusingtime Subset of timeseries data
edit
gettsafteratevent Create timeseries at or after event
edit
gettsafterevent Create timeseries after event
edit
gettsatevent Create timeseries at event
edit
gettsbeforeatevent Create timeseries at or before event
edit
gettsbeforeevent Create timeseries before event
edit
gettsbetweenevents Create timeseries between events
edit
iqr Interquartile range of timeseries data
edit
max Maximum of timeseries data
edit
mean Mean of timeseries data
edit
median Median of timeseries data
edit
min Minimum of timeseries data
edit
std Standard deviation of timeseries data
edit
sum Sum of timeseries data
edit
var Variance of timeseries data
edit

Time Series Collections

edit
tscollection Create tscollection object
edit
addsampletocollection Add sample to tscollection
edit
addts Add timeseries to tscollection
edit
delsamplefromcollection Delete sample from tscollection
edit
horzcat Horizontally concatenate tscollection objects
edit
removets Remove timeseries from tscollection
edit
resample Resample tscollection time vector
edit
set Set tscollection properties
edit
setabstime Set tscollection times as date character vectors
edit
settimeseriesnames Rename timeseries in tscollection
edit
vertcat Vertically concatenate tscollection objects
edit
get Query tscollection properties
edit
getabstime Convert tscollection time vector to cell array
edit
getsampleusingtime Subset of tscollection data
edit
gettimeseriesnames Names of timeseries in tscollection
edit
isempty Determine if tscollection is empty
edit
length Length of tscollection time vector
edit
size Size of tscollection
edit

Time Series Events

edit
tsdata.event Create tsdata.event object
edit
findEvent Query tsdata.event by name
edit
get Query tsdata.event properties
edit
gEttimeStr Query tsdata.event times
edit
set Set tsdata.event properties
edit

Data Type Identification

edit

iscalendarduration Determine if input is calendar duration array

edit

iscategorical Determine whether input is categorical array

edit

iscell Determine whether input is cell array

edit

iscellstr Determine if input is cell array of character vectors

edit

ischar Determine if input is character array

edit

isdatetime Determine if input is datetime array

edit

isduration Determine if input is duration array

edit

isenum Determine if variable is enumeration

edit

isfloat Determine if input is floating-point array

edit

isgraphics True for valid graphics object handles

edit

isinteger Determine if input is integer array

edit

isjava Determine if input is Java object

edit

islogical Determine if input is logical array

edit

isnumeric Determine if input is numeric array

edit

isobject Determine if input is MATLAB object

edit

isreal Determine whether array is real

edit

isstring Determine if input is string array

edit

isstruct Determine whether input is structure array

edit

istable Determine whether input is table

edit

istimetable Determine if input is timetable

edit

is Detect state

edit

isa Determine if input is object of specified class

edit

class Determine class of object

edit

validateattributes Check validity of array

edit

whos List variables in workspace, with sizes and types

edit

Data Type Conversion

edit

char Character array

edit

cellstr Convert to cell array of character vectors

edit

int2str Convert integers to characters

edit

mat2str Convert matrix to characters

edit

num2str Convert numbers to character array

edit

str2double Convert string to double precision value

edit

str2num Convert character array to numeric array

edit

native2unicode Convert numeric bytes to Unicode character representation

edit

unicode2native Convert Unicode character representation to numeric bytes

edit

base2dec Convert text representing number in base N to decimal number

edit

bin2dec Convert text representation of binary number to decimal number

edit

dec2base Convert decimal number to character vector representing base N number

edit

dec2bin Convert decimal number to character vector representing binary number

edit

dec2hex Convert decimal number to character vector representing hexadecimal number

edit

hex2dec Convert text representation of hexadecimal number to decimal number

edit

hex2num Convert IEEE hexadecimal string to double-precision number

edit

num2hex Convert singles and doubles to IEEE hexadecimal strings

edit

table2array Convert table to homogeneous array

edit

table2cell Convert table to cell array

edit

table2struct Convert table to structure array

edit

array2table Convert homogeneous array to table

edit

cell2table Convert cell array to table

edit

struct2table Convert structure array to table

edit

cell2mat Convert cell array to ordinary array of the underlying data type

edit

cell2struct Convert cell array to structure array

edit

mat2cell Convert array to cell array with potentially different sized cells

edit

num2cell Convert array to cell array with consistently sized cells

edit

struct2cell Convert structure to cell array

edit