Matrix 二阶微分方程组的求解

Matrix 二阶微分方程组的求解,matrix,wolfram-mathematica,waveform,differential-equations,Matrix,Wolfram Mathematica,Waveform,Differential Equations,我正在用mathematica编写一个脚本,它将通过数值方法求解波动方程,模拟两端的一根弦并将其拔出 我设置了所有的变量 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

我正在用mathematica编写一个脚本,它将通过数值方法求解波动方程,模拟两端的一根弦并将其拔出

我设置了所有的变量

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::ndinnt:初始条件[Y0 table]不是数字或矩形数组

所以,我似乎对mathematica中的矩阵是如何工作的还没有很好的理解。如果有人能帮助我正确运行最后一行代码,我将不胜感激

谢谢,,
Brad

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

感谢您的快速响应!这有助于推动我朝着正确的方向前进。现在我得到了一个NDSolve::ndnum:在t==0的时候遇到了一个导数的非数值错误,我无法确定它的哪个部分有未定义的变量。
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*)