It's not terribly inefficient, no. However, you don't need to call horzcat
by name:
a = [1:2:9 7:-2:1]
But if you want to avoid the second set of colon
operators, you could flip the first side:
a = 1:2:9;
a = [a fliplr(a(1:end-1))]
But there you have another colon
, and it's definitely more efficient to do it the first way.
Possibly by c = 9; s = 2; b = 1:s:c-2; a = [b c fliplr(b)];
if c-1
is divisible by s
, but I don't see the point of complicating a simple operation like this... unless this is how you get your kicks. ;)