Qurak

Hybrid dynamical systems

ตัวอย่าง 4 ขั้นตอน รันตามลำดับในหนึ่งเซสชัน ทุกขั้นถูกรันกับเอนจินจริง และเอาต์พุตด้านล่างคือสิ่งที่มันให้

ขั้นที่ 1
de[δ_] := {Subscript[x, 1]'[t] == Subscript[x, 2][t], Subscript[x, 2]'[t] == -Subscript[x, 1][t] + 2δ Subscript[x, 2][t] + 1};
ic = {Subscript[x, 1][0] == .5, Subscript[x, 2][0] == .5};
sol = NDSolve[{de[0.1], ic, WhenEvent[And[Subscript[x, 2][t] == 0, Subscript[x, 1][t] < 0], {Subscript[x, 1][t] -> -Subscript[x, 1][t]}]}, {Subscript[x, 1], Subscript[x, 2]}, {t, 0, 500}];

ไม่มีเอาต์พุต - ขั้นนี้ตั้งค่าบางอย่างไว้ให้ขั้นถัดไป

ขั้นที่ 2
Row[Map[ParametricPlot[{Subscript[x, 1][t], Subscript[x, 2][t]} /. sol, {t, 0, #}, PlotPoints -> 500, PlotRange -> {{-1, 2.5}, {-2, 1.5}}]&, {10, 50, 150}]]
เอาต์พุต
-Graphics--Graphics--Graphics-
ขั้นที่ 3
resetOsc[δ_] := NDSolve[{de[δ], ic, WhenEvent[And[Subscript[x, 2][t] == 0, Subscript[x, 1][t] < 0], {Subscript[x, 1][t] -> -Subscript[x, 1][t]}]}, {Subscript[x, 1], Subscript[x, 2]}, {t, 0, 500}];
{sol1, sol2, sol3} = Map[resetOsc, {.1, .15, .2}];

ไม่มีเอาต์พุต - ขั้นนี้ตั้งค่าบางอย่างไว้ให้ขั้นถัดไป

ขั้นที่ 4
Grid[{Map[ParametricPlot[{Subscript[x, 1][t], Subscript[x, 2][t]} /. sol1, {t, 0, #}, PlotPoints -> 500, PlotRange -> {{-3, 3}, {-3, 3}}]&, {10, 50, 150}],
	Map[ParametricPlot[{Subscript[x, 1][t], Subscript[x, 2][t]} /. sol2, {t, 0, #}, PlotPoints -> 500, PlotRange -> {{-3, 3}, {-3, 3}}, PlotStyle -> Green]&, {10, 50, 150}], Map[ParametricPlot[{Subscript[x, 1][t], Subscript[x, 2][t]} /. sol3, {t, 0, #}, PlotPoints -> 500, PlotRange -> {{-3, 3}, {-3, 3}}, PlotStyle -> Red]&, {10, 50, 150}]}]
เอาต์พุต
Grid[{{-Graphics-, -Graphics-, -Graphics-}, {-Graphics-, -Graphics-, -Graphics-}, {-Graphics-, -Graphics-, -Graphics-}}]

ฟังก์ชันที่ใช้

สูตรงานที่เกี่ยวข้อง

สูตรงานทั้งหมด · เอกสารอ้างอิงฟังก์ชัน · ใช้สิ่งนี้จากไคลเอนต์ MCP