我是靠谱客的博主 虚心小松鼠,这篇文章主要介绍ode45函数运行时出错,现在分享给大家,希望可以做个参考。

function dx=numerical(t,x)
dx=zeros(2,1);
e(1)=x(1)-0.5*sin(t);
a=-0.1*e(1)^0.2-40*e(1)^1.2-0.5*e(1)+0.5*cos(t);
w=vpa(dsolve('Dw=(a-w)/0.01'),7);
% w=syms(w);
e(2)=x(2)-w;
dw=(a-w)/0.01;
u=-10*e(2)^0.2-50*e(2)^1.2-0.5*e(2)-e(1)-gaussmf(x(1),[2 4])+dw;
dx(1)=x(2);
dx(2)=u+0.1*x(1)+(1-exp(-23*(t-10)))*5*(x(1)*x(2)+sin(u)+70);

clear;
[t,x]=ode45(@numerical,[0.001 30],[0.3;-0.1]); 
plot(t,x(1),'r',t,x(2),'g')

运行时出现一下结果

目前运行到该语句时会出现错误e(2)=x(2)-w;

从 sym 转换为 double 时出现以下错误:
DOUBLE cannot convert the input expression into a double array.

但不知道该怎么解决,求各位大佬指教

最后

以上就是虚心小松鼠最近收集整理的关于ode45函数运行时出错的全部内容,更多相关ode45函数运行时出错内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(76)

评论列表共有 0 条评论

立即
投稿
返回
顶部