Unexpected behavior defining a function on one line with semi-colons

No it doesn’t.

A = [0 2
     3 4
     5 6]

creates a matrix. ; causes new lines, so

A = [0 2 ; 3 4 ; 5 6]

is the same matrix.

To continue:

A = 1:2
B = 3:4
C = [A
     B]

is vertical concatenation of vectors (vcat). So it makes sense that

C = [A;B]

is vertical concatenation.

1 Like