You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Matlab R2017b中使用dsolve求解微分方程组报错求助

Matlab R2017b中dsolve求解微分方程组出错的原因分析

我是Matlab R2017b新手,尝试用以下脚本求解微分方程组:

clear;
syms k x1(t) x2(t) M b f t;
dx2_1 =diff(x2,t);
dx2_2 =diff(x2,t,t);
dx1_1 =diff(x1,t);
dx1_2 =diff(x1,t,t);

eq1 = k*(x1 - x2) - b*dx2_1 == M*dx2_2;
eq2 = k*(x1-x2) == f;
cond = [x1(0)==0; x2(0)==0; dx2_1(0)==0];
s = dsolve([eq1; eq2],cond); 

运行后出现如下错误:

Warning: Number of equations greater than number of indeterminates. Trying heuristics to reduce to square system. 
> In symengine
  In mupadengine/evalin (line 123)
  In mupadengine/feval (line 182)
  In dsolve>mupadDsolve (line 337)
  In dsolve (line 194)
  In Untitled (line 11) 
Error using mupadengine/feval (line 187)
Unable to reduce to square system because the number of equations differs from the number of indeterminates.

Error in dsolve>mupadDsolve (line 337)
T = feval(symengine,'symobj::dsolve',sys,x,options);

Error in dsolve (line 194)
sol = mupadDsolve(args, options);

Error in Untitled (line 11)
s = dsolve([eq1; eq2],cond);

我认为有两个未知函数x1(t)、x2(t)和两个方程,应该可以求解,而且已经手动解出结果,同时用拉普拉斯变换脚本得到了正确结果:

clear;
syms k x1(t) x2(t) s M b f(t) t;
dx2_1 =diff(x2,t);
dx2_2 =diff(x2,t,t);
dx1_1 =diff(x1,t);
dx1_2 =diff(x1,t,t);

eq1 = k*(x1 - x2) - b*dx2_1 == M*dx2_2;
eq2 = k*(x1-x2) == f;
syms X1 X2 F
EQ1 = laplace(eq1,t,s)
EQ2 = laplace(eq2,t,s)
EQ1= subs(EQ1,[laplace(x1(t), t, s) laplace(x2(t), t, s) laplace(f(t), t, s) subs(diff(x2(t), t), t, 0) x1(0) x2(0)], [X1 X2 F 0 0 0]);
EQ2= subs(EQ2,[laplace(x1(t), t, s) laplace(x2(t), t, s) laplace(f(t), t, s) x1(0) x2(0)], [X1 X2 F 0 0]);
sol=solve([EQ1;EQ2],[X1,X2]);
sol.X1
sol.X2

输出结果:

ans =
 
(F*(M*s^2 + b*s + k))/(k*(M*s^2 + b*s))
 
 
ans =
 
F/(M*s^2 + b*s)

请问我的第一个dsolve尝试哪里出错了?我也曾尝试将所有符号变量替换为数字,但仍出现相同错误。


内容的提问来源于stack exchange,提问作者Lucas Marelli

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.25 14:37:30