解二阶微分方程组

时间:2014-05-04 21:29:08

标签: matrix wolfram-mathematica waveform differential-equations

我正在研究mathematica中的一个脚本,该脚本将通过数值方法求解波动方程来模拟两端的字符串和弹拨。 (http://en.wikipedia.org/wiki/Wave_equation#Investigation_by_numerical_methods

n = 5; (*The number of discreet elements to be used*)
L = 1.0;  (*The length of the string that is vibrating*)
a = 1.0/3.0; (*The distance from the left side that the string is \
plucked at*)
 T = 1; (*The tension in the string*)
[Rho] = 1; (*The length density of the string*)
y0 = 0.1; (*The vertical distance of the string pluck*)
[CapitalDelta]x = L/n; (*The length of each discreet element*)
m = ([Rho]*L)/n;(*The mass of each individual node*)
c = Sqrt[T/[Rho]];(*The speed at which waves in the string propogate*)

我设置了所有变量

Y[t] = Array[f[t], {n - 1, 1}];
MatrixForm(*Creates a vector size n-1 by 1 of functions \
representing each node*)

我定义了我的矢量节点位置函数

K = MatrixForm[
SparseArray[{Band[{1, 1}] -> -2, Band[{2, 1}] -> 1, 
Band[{1, 2}] -> 1}, {n - 1, 
n - 1}]](*Creates a matrix size n by n governing the coupling \
between each node*)

我创建了将所有节点函数相互关联的刚度矩阵

Y0 = MatrixForm[
Table[Piecewise[{{(((i*L)/n)*y0)/a, 
  0 < ((i*L)/n) < a}, {(-((i*L)/n)*y0)/(L - a) + (y0*L)/(L - a), 
  a < ((i*L)/n) < L}}], {i, 1, n - 1}]]

我使用分段函数

定义每个节点的初始位置
NDSolve[{Y''[t] == (c/[CapitalDelta]x)^2 Y[t].K, Y[0] == Y0, 
Y'[0] == 0}, 
Y, {t, 0, 10}];(*Numerically solves the system of second order DE's*)

最后,这应解决各个节点的值,但会返回错误:

“NDSolve :: ndinnt:初始条件[Y0表]不是数字或矩形数组”

因此,我似乎并没有牢牢掌握数学中矩阵的工作原理。如果有人能帮助我让最后一行代码正常运行,我将不胜感激。

谢谢你, 布拉德

1 个答案:

答案 0 :(得分:0)

我认为在定义矩阵时不应该使用MatrixFormMatrixForm用于将列表列表格式化为矩阵,通常在显示时。尝试删除它,看它是否有效。