頁:
[1]
[matlab]使用int函氏來積分
close all;figure
hold on
syms t_o;
d_t=0.01;
x=0;
for t=0:d_t:1
x_d_dot=pi*cos(pi*t/2)/2;
y=-20*x+(pi/2);
f=-(1.5+0.5*sin(t_o))*y^2*cos(3*x);
s=(y-x_d_dot+20*(x-sin(pi*t/2)));
if(s >= 0)
g=1;
else g=-1;
end
u=1.5*(y)^2*cos(3*x)-pi^2*sin(pi*t_o/2)/4-20*(y-x_d_dot)-(0.5*y^2*abs(cos(3*x))+0.1)*g;
% u1=1.5*(y)^2*cos(3*x)-pi^2*sin(pi*t/2)/4-20*(y-x_d_dot)-(0.5*y^2*abs(cos(3*x))+0.1)*g;
x=x+double(int(int(f+u,t_o),t_o,t,t+d_t));
plot(t,u);
end
axis()
在這中想要畫出u的圖形,但在plot(t,u)中卻跑出錯誤Conversion to double from sym is not possible.
請問各位大大這要怎麼解決
...<div class='locked'><em>瀏覽完整內容,請先 <a href='member.php?mod=register'>註冊</a> 或 <a href='javascript:;' onclick="lsSubmit()">登入會員</a></em></div><div></div> 在plot(t,u)之前加 double(u)就可以把sym型態轉回double了
頁:
[1]