How to add some values between two points?

15 ビュー (過去 30 日間)
HONG CHENG
HONG CHENG 2017 年 9 月 20 日
コメント済み: Image Analyst 2017 年 9 月 20 日
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
HONG CHENG 2017 年 9 月 20 日
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
  1 件のコメント
Image Analyst
Image Analyst 2017 年 9 月 20 日
Except that's not what you originally asked for. Originally you had the first column increasing every row.

サインインしてコメントする。

その他の回答 (2 件)

Walter Roberson
Walter Roberson 2017 年 9 月 20 日
編集済み: Walter Roberson 2017 年 9 月 20 日
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.
  1 件のコメント
HONG CHENG
HONG CHENG 2017 年 9 月 20 日
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
Image Analyst 2017 年 9 月 20 日
How about this:
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,:)
  1 件のコメント
HONG CHENG
HONG CHENG 2017 年 9 月 20 日
Thanks for your answer.
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAxis Labels についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by