I have an Nx2 matrix A where each row is an upper bound and lower bound pair and I would like to create an MxN matrix B for which each column is a linspace of M elements from the upper and lower bounds in the coresponding row of A.
For example:
A = [ 2 10 ;
20 100 ;
30 50 ;
0.1 0.5 ]
with a value of 5 for M should give the result:
B = [ 2 20 30 0.1 ;
4 40 35 0.2 ;
6 60 40 0.3 ;
8 80 45 0.4 ;
10 100 50 0.5 ]
I can do this easily with a loop:
B = zeros(M,size(A,1));
for i = 1:size(A,1)
B(:,i) = linspace(A(i,1),A(i,2),M)';
end
but I would like to know a more "Matlab-y" way if possible.