简单的一维自适应控制​算法,目的是画出信号​x的图像,但是dso​lve一直报错!

2 次查看(过去 30 天)
Zhou guoLi
Zhou guoLi 2022-12-2
回答: Dheeraj 2023-9-20
x1.m文件:
function x1=x1(theta,phi,g,u)
x1=theta'*phi+g*u;
end
代码如下:
>> syms x(t) thetah(t) u e
yd=sin(t);
phi=cos(x);
gamma=6;
theta=1;
g=2;
e=x-yd;
c=2;
yd1=diff(yd);
eq1=diff(thetah)==gamma*phi*e;
cond=(thetah(0)==0);
thetah=dsolve(eq1,cond);
u=(-c*e-thetah*phi+yd1)/g;
eq2=diff(x)==x1(theta,phi,g,u);
cond=x(0)==0;
x=dsolve(eq2,cond);
plot(t,x)

回答(1 个)

Dheeraj
Dheeraj 2023-9-20
Hi,
I understand you’re encountering an error using “dsolve” to solve your equations generated.
It is because “dsolve” function only solves ordinary differential equations, but equation-2 of the differential equation has an unsolved integral expression on the right-hand side of it. I.e.
Hence, MATLAB throws an error to provide an ordinary differential equation as function argument. You can re write the "thetah" equation then "dsolve" will give an output of solved expression rather than an unsolved integral.
You can refer to the below MATLAB’s documentation for better understanding of “dsolve”’s capabilities.
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 常微分方程 的更多信息

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!