简单的一维自适应控制算法,目的是画出信号x的图像,但是dsolve一直报错!
2 views (last 30 days)
Show older comments
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)
0 Comments
Answers (1)
Dheeraj
on 20 Sep 2023
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!
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!