JuliaVsMatlab

Julia programming if you already know Matlab

View on GitHub

Main Page

Back to main page

Basic Programming

Comment

Matlab (2020b)Julia (1.6)
% Comment
%{
    Comment line1
    Comment line2
%}
# Comment
#=
Comment line1
Comment line2
=#

Expression

Matlab (2020b)Julia (1.6)
% show calculation result on screen
a = b + 20

% hide calculation result on screen
a = b + 20;

% multiple operations in 1 line
1 + 3; 6 + 10;
# show calculation result on screen
a = b + 20

# hide calculation result on screen
a = b + 20;

# multiple operations in 1 line
1 + 3; 6 + 10;

Multi line expression

Matlab (2020b)Julia (1.6)
a = b + ...
20

% string 'hello world' expressed in two lines
x = ['hello ' ... 
'world'];
a = b +
20

# string "hello world" expressed in two lines
x = "hello " * 
"world";

# No `...` is needed. 
# If statement is incomplete it knows that it will 
# continue in the next line.

# Be careful with
#   a = b
#   + 20
# Instead it will do two operations:
# first assigning `a = b` then showing 20.

Multi line string

Matlab (2020b)Julia (1.6)
multiline = sprintf([ ... 
'Line 1\n'... 
'Line 2\n'... 
]);
multiline = """Line1
Line2
"""