For academic interest, I wish to further improve the speed and memory performance of the included code. The function's purpose, which I've provided below, is to generate a series of linearly spaced vectors using only an input vector for defining the upper and lower limits.
EXAMPLE:
x = [0
12.872
21.453
30.132
40.371
57.631
77.816
100];
increment = 2
y = f(x,increment)
An important aspect to note is that, with the exception of edge conditions, the generated outputs are even and monotonically increasing:
y = [0, ...
12.872, 14, ...
21.453, 22, ...
...
57.631, 58, ...
77.816, 78, ...
The method currently being used is as follows:
function y = multi_linspace(x,increment)
input_length = length(x);
fractional = @(x)([fix(x)*Inf^(x-fix(x)),x]);
for i=1:input_length
if (i ~= input_length)
buffer{i}=ceil(x(i))+mod(ceil(x(i)),2):increment:x(i+1);
edge(1,:)=fractional(x(i));
edge(2,:)=fractional(x(i+1));
id = isinf(edge(:,1));
prefix = id(1); suffix = id(2);
if prefix
buffer{i} = [x(i),buffer{i}];
end
if suffix
buffer{i} = [buffer{i},x(i+1)];
end
end
end
y=[buffer{:}]';
end