For the final review of mathematical modeling, I wrote a blog to make a summary, mainly focusing on the establishment of the model of the example and the realization of part of the code.

Matlab differential solution toolbox

  • The numerical solution

Dsolve (‘ Equation 1 ‘, ‘Equation 2’… , ‘equation n’, ‘initial conditions’,’ independent variables’)

  • Analytical solutions for

[t, x] = solver (” f “, ts, x0, options)

Detailed instructions can refer to the blog Matlab differential equation solution

Missile –

Problem is introduced

  • Ship A, located at the origin of coordinates, fires A missile to ship B, located at point A(1, 0) on the X-axis, with the missile head always pointing at ship B. If ship B is traveling in a straight line parallel to the Y-axis at the maximum velocity v0V_0v0 (constant), the missile’s velocity is 5 v0v_0v0, find the curve equation for the missile’s movement. How far did the missile hit ship B?

Model establishment and solution

1. The analytic method

Model building: Suppose the position of the missile at time T is P(x(t),y(t)) and ship B is located at Q (1, V0tV_0tV0t). It can be obtained from the question (the missile head is always aligned with ship B). The tangent of missile in the motion curve point p y ‘= v0t – y1 – y ^ {\ prime} = \ frac {v_ t – y} {0} {1} x y’ = 1 – xv0t – namely v0t y = (1 -) x y ‘+ y v_ (1) {0} t = (1 – x) Y ^ {\ prime} + y (1) v0t = (1 -) x y ‘+ y (1) and by the question (missile speed ship is five times) it is: ∫ 0 x1 + y dx = 5 ‘2 v0t (2) \ int_0 ^ {\ SQRT {1 + y {‘ x ^ 2}}} {\ rm {d}} x = 5 (2) {v_0} t ∫ 0 x1 + y dx = 5’ 2 v0t (2) there are (1) (2) can be differential differential equations as follows: (1 -) x y ‘y’ ‘= 151 + 2 (3) (1 -) x y ^ = {\ prime \ prime} \ frac {1} {5} \ SQRT {1 + y ^ {2} \ prime} (3) (1 -) x y’ y ‘ ‘= 511 + 2 (3) initial value equation for: Y (0) = 0, y = 0 (0) y (0) = 0, y ‘(0) = 0, y’ (0) = 0, y ‘(0) = 0, use Matlab to solve available: Y = 45 + 512-58 (1 -) x (1 -) x + y = 524-65 \ frac {5} {8} {(1 -) x ^ {\ frac {4} {5}}} + \ frac {5} {{12}} {(1 -) x ^ {\ frac {6} {5}}} + \ frac {5} {{24}} y = 54 + 125-85 (1 -) x (1 -) x + 245 to 56

2. Numerical solution

Reduce the above equation to a first-order equation, Might as well set y = y1, y2 = y ‘y_1 = y, y_2 = y’ y = y1, y2 = y ‘, plug (3) of {y1 ‘= y2y2’ = 151 + y12 / (1 -) x \ left \ {\ begin {array} {l} y_ {1} ^ {\ prime} = y_ {2} \ \ Y_ {2} ^ = {\ prime} \ frac {1} {5} \ SQRT {1 + y_ {1} ^ {2}} / (1 -) x {array} \ \ end right. {y1 ‘= y2y2’ = 511 + y12/1 – (x) using Matlab to solve:

% define functionfunction dy=eq1(x,y)
    dy=zeros(2.1);
    dy(1)=y(2);
    dy(2) =1/5*sqrt(1+y(1) ^2)/(1-x); Call x0 = end0;
xf=0.9999;
[x,y]=ode15s('eq1',[x0 xf],[0 0]);
plot(x,y(:,1),The '-') 
hold on
y=0:0.01:2;
plot(1,y,The '*')
Copy the code

As can be seen from the figure, the missile struck ship b approximately at point (1,0.2).

Parametric equations

Assuming the above conclusion remains unchanged, based on this, the velocity of the missile is set as WWW, then at point P: (DXDT) 2 + 2 = w2 (dydt) (1) {({{x} {\ rm {d}} \ over {t} {\ rm {d}}}) ^ 2} + {, {{{\ rm {d}}} y \ over {t} {\ rm {d}}}) ^ 2} = {w^2} (1) (DTDX)2+(dtdy)2=w2 (1) At the same time, the missile is always aligned with ship B, that is, the velocity vector of the missile is parallel to the position vector of ship B, so:

\frac{\mathrm{d} x}{\mathrm{d} t} \\ \frac{\mathrm{d} y}{\mathrm{d} t} \end{array}\right)=\lambda\left(\begin{array}{l} X-x \\ Y-y \end{array}\right), \ quad \ lambda > 0, (2) $$$$\ left \ {\ begin {array} {l} \ frac {\ mathrm x} {d} {\ mathrm {d} t}=\frac{w}{\sqrt{(X-x)^{2}+(Y-y)^{2}}}(X-x) \\ \frac{\mathrm{d} y}{\mathrm{d} T} = \ frac {w} {\ SQRT {(X – X) ^ (Y – Y) ^ {2} + {2}}} – Y – Y) {array} \ \ end right. (3) the ship speed is 1 $$presupposes b, w = 5, X = 1, Y = t, at this time the parameters of the missile trajectory as follows: $$\left\{\begin{array}{l} \frac{\mathrm{d} x}{\mathrm{d} t}=\frac{5}{\sqrt{(1-x)^{2}+(t-y)^{2}}}(1-x) \\ \frac{\mathrm{d} y}{\mathrm{d} t}=\frac{5}{\sqrt{(1-x)^{2}+(t-y)^{2}}}(t-y) \\ x(0)=0, Function dy=eq2(t,y) dy=zeros(2,1); function dy=eq2(t,y) dy=zeros(2,1); dy(1)=5*(1-y(1))/sqrt((1-y(1))^2+(t-y(2))^2); dy(2)=5*(t-y(2))/sqrt((1-y(1))^2+(t-y(2))^2); End % call [t,y]=ode45(‘eq2′,[0 2],[0 0]); Y = 0-0. 01:2; plot(1,Y,’-‘) hold on plot(y(:,1),y(:,2),’*’) “` ! [insert picture description here] (HTTP: / / https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/c12063ad33dd4333b64448e9ae4d3075~tplv-k3u1fbpfcp-zoom-1.im As can be seen from the figure, the missile finally hits the target roughly at (1,0.2). Here also try to use the idea of dichotomy to further get a more accurate answer… Tf =0.21, the solved image is:! [insert picture description here] (HTTP: / / https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/b4f9a6123c24433383fcd64a18b1adfa~tplv-k3u1fbpfcp-zoom-1.im From this, a more accurate answer can be obtained.