Synchronize the intersection points of two pairs of curves with fminsearch

I have two pairs of curves, and each pair has an intersection point with a different time value (x-value). Now I need to move one curve of each pair evenly in the x direction , until both intersection points have the same time value / x argument:

enter image description here

, (, , ) , . x- ( ). (1 = 2 = ) x-, .

, :

t1 = linspace(0,3,30);
t2 = linspace(0,5,15);
x1 = t1.^2.*5;
x2 = -t2.^2.*3+50;
y1 = t1.*2;
y2 = t2;

ip_x = InterX([t1;x1],[t2;x2]);
ip_y = InterX([t1;y1],[t2;y2]);

, , InterX File Exchange, x y . , .

, ?

[ t1,x1,y1,t2,x2,y2 ] = findIntersectPair(t1,x1,y1,t2,x2,y2);

fminsearch, .

function [ t1,x1,y1,t2,x2,y2 ] = findIntersectPair(t1,x1,y1,t2,x2,y2)

d0 = 0;

[d,dxy] = fminsearch(@findDelay,d0);

function dxy = findDelay( d )
    disp(['d = ' num2str(d)])
    t2 = t2 - d;
    ip1 = InterX([t1;x1],[t2;x2]);
    ip2 = InterX([t1;y1],[t2;y2]);
    dxy = ip1(1)-ip2(1);
    disp(['dxy = ' num2str(dxy)])
end


[t1,x1,y1,x2,y2] = deal(t1,x1,y1,x2,y2);
t2 = t2 - d;

end

d 0 , dxy ( 2.5 ) 0.

, , - d , :

d = 0
dxy = 2.4998
d = 0.00025
dxy = 2.4995
...
d = 0.00175
dxy = 2.4936
d = 0.00275
dxy = 2.4898
...
d = 0.38375
dxy = 0.67101
d = 0.51175
dxy = -0.11166
d = 0.76775

fmincon. . ?

+4
1

fmincon - , , .

: t2 = t2 - d , t2 , . .

tt .

:

function [ t1,x1,y1,t2,x2,y2 ] = findIntersectPair(t1,x1,y1,t2,x2,y2)

[d,dxy] = fminsearch(@findDelay,0);

function dxy = findDelay( d )
    tt = t2 - d;
    ipx = InterX([t1;x1],[tt;x2]);
    ipy = InterX([t1;y1],[tt;y2]);
    dxy = abs(ipx(1)-ipy(1));
end

[t1,x1,y1,x2,y2] = deal(t1,x1,y1,x2,y2);
t2 = t2 - d;

end

:

enter image description here

+1

All Articles