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

조회 수: 7 (최근 30일)
Zhou guoLi
Zhou guoLi 2022년 12월 2일
댓글: 2025년 6월 30일
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!
  댓글 수: 1
钰
2025년 6월 30일
thanks!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 数学에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!