equal distances

14 次查看(过去 30 天)
priscilla
priscilla 2011-7-13
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
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 个评论
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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by