是 NDSolve 和其他函数的一个选项,指定在提供的方程式中,所有被认为是从属变量的对象的列表.
DependentVariables
是 NDSolve 和其他函数的一个选项,指定在提供的方程式中,所有被认为是从属变量的对象的列表.
更多信息
- 设置 DependentVariables->Automatic 时,应变量从方程判断.
- DependentVariables->{u1,u2,…} 指定从属变量 ui 的完整列表,表示所要求解的函数,即使不能最终返回解.
- DependentVariables->{uspec1,uspec2,…} 可用于指定应变量范围.
- uspeci 的可能形式是:
-
u u 具有范围 Reals 或者 Complexes Element[u,Reals] u 具有范围 Reals Element[u,Complexes] u 具有范围 Complexes Element[u,{v1,…}] u 具有离散范围 {v1,…} {u,umin,umax} u 具有范围 
uspeciactioni 执行 actioni 当 uspeci 不再满足
范例
打开所有单元 关闭所有单元基本范例 (2)
xsol = NDSolve[{x'[t] == y[t], y'[t] == -Sin[x[t]], x[0] == 3.1, y[0] == 0}, x, {t, 0, 20}, DependentVariables -> {x, y}]Plot[x[t] /. xsol, {t, 0, 20}]sol = NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 10}, DependentVariables -> {{y[t], 0, 3}}]Plot[y[t] /. sol, {t, 0, 1.1}]范围 (4)
a = 1;NDSolve[{y'[t] == a y[t], y[0] == 2}, y, {t, 0, 1}, DependentVariables -> {{y, 0, 3}, {y, 1, 4}}]a = -1;NDSolve[{y'[t] == a y[t], y[0] == 2}, y, {t, 0, 1}, DependentVariables -> {{y, 0, 3}, {y, 1, 4}}]{sol, {point}} = NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 2}, DependentVariables -> {{y[t], 0, 5} :> {Print[{t, y[t]}], Sow[{t, y[t]}]}}]//Reap;Plot[y[t] /. sol, {t, 0, 2}, Epilog -> {PointSize[Medium], Point[point]}]{sol, {points}} = NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y, {t, 0, 20}, DependentVariables -> {{y[t], -.5, .5} :> Sow[{t, y[t]}]}]//Reap;Plot[y[t] /. sol, {t, 0, 20}, Epilog -> {PointSize[Medium], Point[points]}]NDSolve[{y''[t] == -y[t], y[0] == 0, y'[0] == 1}, y, {t, 0, 20}, DependentVariables -> {{y[t], -.5, .5} :> {Print[{ t, y[t]}], "StopIntegration"}}]应用 (2)
n = 1000;
vars = Table[Subscript[x, i][t], {i, n}];
eqns = Table[j = Mod[i, n] + 1;{Subscript[x, i]'[t] == 1 / (Subscript[x, i][t] + Subscript[x, j][t])^2, Subscript[x, i][0] == 1 / i}, {i, n}];Short[eqns, 3]sol = NDSolve[eqns, Subscript[x, 1], {t, 0, 100}, DependentVariables -> vars]Plot[Subscript[x, 1][t] /. sol, {t, 0, 100}, PlotRange -> All]allsol = NDSolve[eqns, vars, {t, 0, 100}];{ByteCount[sol], ByteCount[allsol]}de[a_] := With[{ω = 50}, θ''[t] - (-9.8 / 10)Sin[θ[t]] == -(a / 10)ω ^ 2 Sin[ω t]Sin[θ[t]]];
ic = {θ[0] == π, θ'[0] == 0.01};sol = NDSolve[{de[5], ic}, θ, {t, 0, 2}, DependentVariables -> {{θ[t], 2, 4}}]Plot[θ[t] /. sol, {t, 0, 1.0732}, PlotRange -> {2, 4}]sol = NDSolve[{de[2], ic}, θ, {t, 0, 2}, DependentVariables -> {{θ[t], 2, 4}}];Plot[θ[t] /. sol, {t, 0, 2}, PlotRange -> {3.139, 3.145}]属性和关系 (1)
变量范围检查也可以使用 WhenEvent 得到:
NDSolve[{y'[t] == y[t], y[0] == 1, WhenEvent[(y[t] + 10)(y[t] - 10), "StopIntegration"]}, y, {t, 0, 10}]带有 DependentVariables 的等价范围检查更直接并且全面:
NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 10}, DependentVariables -> {{y[t], -10, 10}}]WhenEvent 对更复杂的范围检查有用:
NDSolve[{y'[t] == y[t], y[0] == 1, WhenEvent[y[t] ^ 8 - y[t] - 2, "StopIntegration"]}, y, {t, 0, 10}]可能存在的问题 (3)
NDSolve[{y'[t] == a[t]y[t], y[0] == 1, a[0] == 1}, y, {t, 0, 1}, DiscreteVariables -> {a}, DependentVariables -> {a, y}]NDSolve[{y'[t] == y[t], y[0] == 1}, y, {t, 0, 1}, DependentVariables -> {Element[y[t], {0, 1, 2, 3}]}]NDSolve[{y'[t] == y[t], y[0] == 0.5}, y[t], {t, 0, 1}, DependentVariables -> {{y[t] ^ 2, 0, 1}}]NDSolve[{y'[t] == y[t], y[0] == 0.5}, y[t], {t, 0, 1}, DependentVariables -> {{y[t], -1, 1}}]或者在方程中使用 WhenEvent 表达式:
NDSolve[{y'[t] == y[t], WhenEvent[y[t]^2 == 1, "StopIntegration"], y[0] == 0.5}, y[t], {t, 0, 1}]相关指南
历史
2003年引入 (5.0) | 在以下年份被更新:2012 (9.0)
文本
Wolfram Research (2003),DependentVariables,Wolfram 语言函数,https://reference.wolfram.com/language/ref/DependentVariables.html (更新于 2012 年).
CMS
Wolfram 语言. 2003. "DependentVariables." Wolfram 语言与系统参考资料中心. Wolfram Research. 最新版本 2012. https://reference.wolfram.com/language/ref/DependentVariables.html.
APA
Wolfram 语言. (2003). DependentVariables. Wolfram 语言与系统参考资料中心. 追溯自 https://reference.wolfram.com/language/ref/DependentVariables.html 年
BibTeX
@misc{reference.wolfram_2026_dependentvariables, author="Wolfram Research", title="{DependentVariables}", year="2012", howpublished="\url{https://reference.wolfram.com/language/ref/DependentVariables.html}", note=[Accessed: 08-September-2026]}
BibLaTeX
@online{reference.wolfram_2026_dependentvariables, organization={Wolfram Research}, title={DependentVariables}, year={2012}, url={https://reference.wolfram.com/language/ref/DependentVariables.html}, note=[Accessed: 08-September-2026]}