equal distances

14 visualizzazioni (ultimi 30 giorni)
priscilla
priscilla il 13 Lug 2011
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

Risposte (1)

Friedrich
Friedrich il 13 Lug 2011
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 Commenti
Friedrich
Friedrich il 13 Lug 2011
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 il 13 Lug 2011
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.

Accedi per commentare.

Categorie

Scopri di più su MATLAB in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by