Intersection point of two lines from the data set.

1 回表示 (過去 30 日間)
Arsal15
Arsal15 2016 年 1 月 28 日
コメント済み: Star Strider 2016 年 1 月 28 日
Hi, How points on a line can be calculated if you are given the lower(x1,y1) and the upper(x2,y2) points and a given speed from (x1,y1)to(x2,y2).
if you can guide. ?

回答 (2 件)

Star Strider
Star Strider 2016 年 1 月 28 日
For a linear plot like that, the easiest way would be to use the polyfit and polyval functions:
p = polyfit([x1; x2], [y1; y2], 1); % Fit Line To Known Points With Linear Approximation
x3 = ... SOME POINT OR VECTOR OF POINTS ...; % Desired ‘x’ Values
y3 = polyval(p, x3); % Calculate ‘y’ Values
If ‘x’ is time and ‘y’ is position, the speed will be given by ‘p(1)’.
  2 件のコメント
Arsal15
Arsal15 2016 年 1 月 28 日
Sorry to ask again. I am confused in your variables?
Can you take these variables and guide me? As I have taken below. Now if I have another time instant like 5.5 which is in between [4.8133 and 5.9180] then what will be x and y coordinates of that point at instant 5.5? For sure that point will be on that line ?
if true
x_position = [x(1) x(2)] = [0.0988 0.0442];
y_position = [y(1) y(2)] = [8.2928 8.2941];
time_at_positions = [t(1) t(2)] = [4.8133 5.9180];
speed_x_direction = [vx(1) vx(2)] = [-0.0132 -0.1592];
speed_y_direction = [vy(1) vy(2)] = [-0.0003 0.0389];
end
I will be thankful if you can guide me . As I am stuck on this point.
Star Strider
Star Strider 2016 年 1 月 28 日
I would use the interp1 function:
x = [0.0988 0.0442];
y = [8.2928 8.2941];
t = [4.8133 5.9180];
tq = 5.5;
xy = interp1(t', [x; y]', tq)
xy =
64.8597e-003 8.2936e+000
I’m still not certain I’m understanding the problem, but this seems at least to be working toward a solution.

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


Image Analyst
Image Analyst 2016 年 1 月 28 日
See attached polyfit demo.
  1 件のコメント
Arsal15
Arsal15 2016 年 1 月 28 日
Can you please also look into my comment above and give your suggestion.
I will be grateful for your kind reply.

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

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by