If you're using 2016a or earlier, you'll want to use bsxfun:
>> A = [1 2 3 4 5]; >> bsxfun(@minus, A.', A) ans =
0 -1 -2 -3 -4
1 0 -1 -2 -3
2 1 0 -1 -2
3 2 1 0 -1
4 3 2 1 0
Starting in 2016b (or in Octave), you can take advantage of implicit expansion and do away with bsxfun:
>> A.' - A ans =
0 -1 -2 -3 -4
1 0 -1 -2 -3
2 1 0 -1 -2
3 2 1 0 -1
4 3 2 1 0