matlab求解微分方程报错

16 次查看(过去 30 天)
Xin Li
Xin Li 2022-3-10
软件情况:64位matlab-R2019a需要用到:Symbolic Math Toolbox
这是程序代码
[function Fin = f(t)
f0=0.012;
t1=5;
tend=360;
a=0.5;
if t>=t1 && t<=tend
Fin = (1+a)*f0;
elseif t>0 && t<t1
Fin = f0+(a*f0)/t1.*t;
elseif t>tend && t<tend+t1
Fin = (1+a)*f0-(a*f0)/t1.*(t-tend);
else
Fin=0.012;
end
end
t=0:1:800;
n=length(t);
fin=[];
for i=1:n
Fin=f(t(i));
fin=[fin Fin];
end
Vv=[];
for i=1:n
Vv1=dsolve('Dvv=fin(i)-0.012*(vv/0.0237)^2/(35*0.012*(vv/0.0237)^-0.5-1)','0.23') ;
Vv=[Vv Vv1];
end]
报错的位置主要在Vv1=dsolve('Dvv=fin(i)-0.012*(vv/0.0237)^2/(35*0.012*(vv/0.0237)^-0.5-1)','0.23') ;这一句,当我去掉后面的参数'0.23时',可以运行,但求不出解析解,执行结果如下
警告: Unable to find explicit solution. Returning implicit solution instead.
> In dsolve (line 208)
In Untitled (line 10)
当我加上'0.23'这个参数时,反而报错不能运行了,运行结果如下
错误使用 mupadengine/feval (line 195)
Invalid equations.
出错 dsolve>mupadDsolve (line 340)
T = feval(symengine,'symobj::dsolve',sys,x,options);
出错 dsolve (line 194)
sol = mupadDsolve(args, options);
出错 Untitled (line 10)
Vv1=dsolve('Dvv==(fin(i)-0.012*(vv/0.0237)^2/(35*0.012*(vv/0.0237)^-0.5-1))','0.23') ;

回答(1 个)

Anjaneyulu Bairi
Anjaneyulu Bairi 2024-1-10
Hi,
I understand that you are getting error while solving differential equation using dsolve” function. The dsolve” function should have second argument as condition like vv(0)=0.23. Change the second argument to 'vv(0)=0.23' and it works.
Visit the following documentation link for more information on “dsolve” - https://in.mathworks.com/help/symbolic/dsolve.html
Hope it helps to resolve your query.

类别

Help CenterFile Exchange 中查找有关 Symbolic Math Toolbox 的更多信息

产品


版本

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!