Intersection point of two lines from the data set.
1 view (last 30 days)
Show older comments
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. ?
0 Comments
Answers (2)
Star Strider
on 28 Jan 2016
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 Comments
Star Strider
on 28 Jan 2016
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.
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!