equal distances

Hai,
Known is a list of x and y coordinates and with this the distances (sqrt(x^2+y^2). Now I want to have the x and y coordinates out of the old xy coordinates with same distances. So we tried interp1(d,xy,di) = xyi, with d the old distances, di the new distances ( d = [0; cumsum(d)]; di = linspace(0,d(end),200);) end xy = [x y] the old xyvalues and xyi the new xy values. But unfortunately this doesn't give xyvalues with same distances between following up coordinates. So we need something like a derived function of interp2; because interp2(x,y,z,xi,yi)=zi and we know x y z zi, but unknown xi and yi.
Thanks for helping me

답변 (1개)

Friedrich
Friedrich 2011년 7월 13일

0 개 추천

Hi,
I hope I get it right. I would do something like this:
clc
%some points
x = rand(100,1);
y = rand(100,1);
%hard to generate random points with same distance, so generate manually
%one pair
x(end+1) = -x(1);
y(end+1) = -y(1);
%choose a distance
dist = sqrt(x(1)^2 + y(1)^2);
%check for same distance
logic = abs((sqrt((x.^2 + y.^2)) - dist)) < eps;
disp('x = ')
x(logic)
disp('y =')
y(logic)
disp('distance')
sqrt(x(logic).^2 + y(logic).^2)

댓글 수: 3

priscilla
priscilla 2011년 7월 13일
Hai,
I don't want to check for same distances,
but I want to get same distances by making new x and y values out of the old ones.
Friedrich
Friedrich 2011년 7월 13일
Is there any relation between the new and old values? If not, you can take the old x values, multiply those with some random numbers (make sure the new_x isnt bigger than the distance) and than recalculate the needed y values.
Sean de Wolski
Sean de Wolski 2011년 7월 13일
yes. You know R must be the same, so pick a random x or y and calculate the required x/y to make the distance expression true.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2011년 7월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by