我正在尝试在matlab中创建自己的函数来求解一个常微分方程组,这里是代码:
function dw = fun(t,w)
n = 17;
c = 1; h = 1/n; r = (c/h)^2;
Id = ones( n - 2, 1 ); Id_off = ones( n - 3, 1 );
Z = zeros( n - 2, n - 2 );
M = diag( -2*r*Id ) + diag( r*Id_off, 1 ) + diag( r*Id_off, -1 );
M = [Z eye( n - 2, n - 2 ); M Z];
v = zeros( 2*n - 4, 1 );
a = 0; b =0;
v(n - 1) = r*a; v(end) = r*b;
dw = M*w + v;
end
当我运行m文件时,它会给出错误消息:“没有足够的输入参数”
我该如何解决这个问题呢? 提前致谢