在mathematica中,如何将初始条件作为ndsolve中的变量?
我想要这样的东西,
w[w1_] :=
NDSolve[{y''[x] + y[x] == 2, y[0] == w1, y'[0] == 0}, y, {x, 0, 30}]
这看起来效果更好,但我想我错过了 smtn,
w := NDSolve[{y''[x] + y[x] == 2, y[0] == w1, y'[0] == 0},
y, {x, 0, 30}]
w2 = Table[y[x] /. w, {w1, 0.0, 1.0, 0.5}]
因为当我尝试制作表格时,它不起作用:
Table[Evaluate[y[x] /. w2], {x, 10, 30, 10}]
我收到错误:
ReplaceAll::reps: {<<1>>[x]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
ps:有更好的地方吗问这样的问题? mathematica 没有支持的论坛,只有 mathGroup 电子邮件列表。如果 stackoverflow 能有更具体的 mathematica 标签,比如简化、ndsolve、绘图操作,那就太好了
i'd like to have something like this
w[w1_] :=
NDSolve[{y''[x] + y[x] == 2, y[0] == w1, y'[0] == 0}, y, {x, 0, 30}]
this seems like it works better but i think i'm missing smtn
w := NDSolve[{y''[x] + y[x] == 2, y[0] == w1, y'[0] == 0},
y, {x, 0, 30}]
w2 = Table[y[x] /. w, {w1, 0.0, 1.0, 0.5}]
because when i try to make a table, it doesn't work:
Table[Evaluate[y[x] /. w2], {x, 10, 30, 10}]
i get an error:
ReplaceAll::reps: {<<1>>[x]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>
ps: is there a better place to ask questions like that? mathematica doesn't have supported forums and only has mathGroup e-mail list. it would be nice if stackoverflow would have more specific mathematica tags like simplify, ndsolve, plot manipulation
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有很多方法可以做到这一点。一是:
输出:
There are a lot of ways to do that. One is:
Output:
我看到你已经选择了一个答案,但我想把这个线性方程组的解决方案扔掉。具体来说,这是对 Lotka-Volterra 的轻微变化进行建模。
然后我们可以使用 Animate(或 table,但 animate 非常棒)
I see you already chose an answer, but I want to toss this solution for families of linear equations up. Specifically, this is to model a slight variation on Lotka-Volterra.
We can then use Animate (or table, but animate is awesome)