# How to add some values between two points？

50 views (last 30 days)
HONG CHENG on 20 Sep 2017
Commented: Image Analyst on 20 Sep 2017
Dear everyone, Now I have some coordinates pairs and I want to add more points in the area.
For example, If I have the dataset
A = [1,2;2,2;1,3;2,3]
I want to get the matrix
B = [1, 2 ; 1.1, 2; 1, 2.1 ;1.1, 2.1; ..... ; 1.9, 2.9; 2.9, 3; 2, 2.9 ; 2, 3 ]  Thanks a lot

HONG CHENG on 20 Sep 2017
In here, I didn't use any special function. but the result looks not bad
Xmin = 1;
Ymin = 2;
Xmax = 2;
Ymax = 3;
step = 0.1;
step_1 = 1/0.1;
K = (Xmax-Xmin)*(Ymax-Ymin)*step_1*step_1;
Co = zeros(K,2);
n_Co = 1;
for i = Xmin:step:Xmax
for j = Ymin:step:Ymax
Co(n_Co, 1) = i;
Co(n_Co, 2) = j;
n_Co = n_Co+1;
end
end
My result is in the following Image Analyst on 20 Sep 2017
Except that's not what you originally asked for. Originally you had the first column increasing every row.

Walter Roberson on 20 Sep 2017
Edited: Walter Roberson on 20 Sep 2017
r = linspace( min(A(:,1)), max(A(:,1)), 11 );
c = linspace( min(A(:,2)), max(A(:,2)), 11 );
11 is needed instead of 10 because you need to include the final value.
HONG CHENG on 20 Sep 2017
Thanks for your quick answer. And now we get the linspace for X and Y, but I need a matrix of them as the picture shows, I want to get the values as the blue block area shows~~~

Image Analyst on 20 Sep 2017
n = 20 % Whatever...
A = [1,2;2,2;1,3;2,3]
% Make new linearly interpolated array.
A2 = imresize(A, [n, 2])
A2 = A2(3 : end-2,:)
HONG CHENG on 20 Sep 2017
And I have tried your method, but the result looks a little strange
0.876250000000000 2
0.886250000000000 2
0.906250000000000 2
0.936249999999999 2
0.976250000000000 2
1.02981250000000 1.99881250000000
1.11493750000000 1.99043750000000
1.22656250000000 1.97656250000000
they are not uniform
Now I write my own code in the following answer.maybe there is a better method
Thanks a lot