clf
clc
function dx=f(t,x)
dx(1) = x(2)
dx(2) = -B*(1-x^2)*x(2)-w*w*x(1)
endfunction
B = 5
w = 1
x0 = [10;100]
t = 0:0.01:10
x = ode(x0,0,t,f)
plot2d(t,x)
现在它在 scilab 控制台中显示以下问题...
at line 3 of function f ( /Users/mottelet/so.sce line 7 )
in builtin ode
at line 15 of executed file /Users/mottelet/so.sce
Submatrix incorrectly defined.
ode: An error occurred in 'lsoda' subroutine.
请告诉我我做错了什么并告诉解决方案。
你f
在这一行的函数代码有问题
dx(2) = -B*(1-x^2)*x(2)-w*w*x(1)
因为该表达式-B*(1-x^2)*x(2)
生成一个向量,而您尝试将其分配给一个标量容器(此处为dx(2)
)。也许你想写-B*(1-x(1)^2)*x(2)
或-B*(1-x(2)^2)*x(2)
(即用x
它的一个组件替换第一次出现的)?
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句