Lateral Deviation Between two curves
Ältere Kommentare anzeigen
How can the lateral deviation be calculated and drawn between two curves? For instance i have two paths; a desired path and a driven path. I would like to find the lateral deviation or error from the driven path to the desired path and also display the error as a connecting line. Apparently theres a way to do this that uses the normal to the tangent at each point of the driven line, however, i cant quite forget out how to go about that information.
close all; clear all; clc;
for i = 1:100
x(i) = i;
desired_path(i) = 10+x(i).^2;
driven_path(i) = .5*x(i).^2;
end
figure
hold on
plot(x(:), desired_path(:));
grid on;
plot(x(:), driven_path(:));
legend('Desired Path', 'Driven Path')
hold off;

1 Kommentar
Torsten
am 28 Okt. 2022
You mean a plot of abs(f^(-1)(y) - g^(-1)(y)) over y if f(x) = desired path and g(x) = driven path ?
Antworten (2)
desired_path_invers = @(y)sqrt(y-10);
true_path_invers = @(y)sqrt(2*y);
y = 10:0.1:12000;
plot(y,abs(desired_path_invers(y)-true_path_invers(y)))
The normal to "driven_path" and the "desired_path" do not cross for r(4) < x < r(2). That's why there is a gap in the distance graph.
syms x t
driven_path = 0.5*x^2;
desired_path = t^2 + 10;
normal_to_driven_path = 0.5*x^2 - 1/x*(t-x);
T = solve(normal_to_driven_path == desired_path,t)
p = [2 0 -36 0 1];
r = roots(p)
cutpoint1 = subs(desired_path,t,T(1))
cutpoint2 = subs(desired_path,t,T(2))
dist1 = norm(-[x,driven_path]+[T(1),cutpoint1]);
dist2 = norm(-[x,driven_path]+[T(2),cutpoint2]);
dist1 = matlabFunction(dist1);
dist2 = matlabFunction(dist2);
x1 = 1e-8:0.0001:r(4);
x2 = r(2):0.001:15;
x3 = r(3):0.0001:-1e-8;
x4 = -15:0.001:r(1);
plot(x1,dist1(x1),'r',x2,dist1(x2),'r',x3,dist1(x3),'r',x4,dist1(x4),'r')
Kategorien
Mehr zu Line Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!





