MATLAB: Use linspace without scalar input

I want to use linspace that goes from two non-scalar terms. Is there a way to use linspace with specified number of points, n, for decimal values for inputs? Example code is below for what I am looking for.
x = 0.01;
y = [1.01, 3.01];
n = 10;
dxy = linspace(x, y, n);

Best Answer

x = 0.01;
y = [1.01, 3.01]; %would be better as a column vector as you wouldn't to tranpose it in the arrayfun

n = 10;
dxy = cell2mat(arrayfun(@(e) linspace(x, e, n), y', 'UniformOutput', false))
Or using a loop:
x = 0.01;
y = [1.01, 3.01]; %would be better as a column vector as you wouldn't to tranpose it in the arrayfun
n = 10;
dxy = zeros(numel(y), n);
for row = 1:numel(y)
dxy(row, :) = linspace(x, y(row), n);
end
or using Jan's idea but with R2016b or later syntax:
x = 0.01;
y = [1.01, 3.01]; %would be better as a column vector as you wouldn't the transpose in the calculation of dxy
n = 10;
dxy = (0:n-1) .* (y'-x)/n + x
Related Question