声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1911|回复: 2

[近似分析] 请教一个用matlab解微分方程的小问题?

[复制链接]
发表于 2007-5-16 14:31 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
用matlab解微分方程组的时候,方程组中有sin,cos函数怎么办?怎么编呢?要不要先用泰勒展开先呢,ode45能不能直接解这样的方程组啊?
例:
function xdot=0000001(t,x,dummy,tau1,tau2,K,Deltaomegao)
         xdot=zeros(2,1);
         xdot(2)=(-(1/tau1+K*tau2*sin(x(1))/tau1)*x(2)-K*cos(x(1))/tau1+Deltaomegao/tau1);
         xdot(1)=x(2);
还是要展开先呢?将下程序保存为TwoPLL2.m
function xdot=TwoPLL2(t,x,dummy,tau1,tau2,K,Deltaomegao)
         xdot=zeros(2,1);
         xdot(2)=(-(1/tau1+K*tau2*(1-x(1)^2/2+x(1)^4/24)/tau1)*x(2)-K*(x(1)-x(1)^3/6+x(1)^5/120)/tau1+Deltaomegao/tau1);
         xdot(1)=x(2);
不过自己展开的话精确度就小了很多,因为自己展开不有写出很多项,只能展开前几项啊,能解决这个问题吗?
主程序:
tau1=5;tau2=1;K=12;Deltaomegao=[1,2,3,4,5,6,7,8,9,10];
tspan=linspace(0,15,1500);
options=odeset('Abstol',[1e-6,1e-6]);
for i=1:10
     [t,x]=ode15s('TwoPLL2',tspan,[-pi,Deltaomegao(i)]',options,tau1,tau2,K,Deltaomegao(i));
     figure(1);plot(t,x(:,1));       hold on; title('Phase difference as a function of Time');ylabel('θe(t)/rad');xlabel('t/s');
     figure(2);plot(t,x(:,2));       hold on; title('Frequency difference as a function of Time');ylabel('(dθe(t)/dt)/(rad?sˉ1)');xlabel('t/s');
     figure(3);plot(x(:,1),x(:,2));  hold on; title('Phase portrait');ylabel('(dθe(t)/dt)/(rad?sˉ1)');xlabel('/rad');
end
可以运行一下,没有错误的,我有运行过了的。:handshake
回复
分享到:

使用道具 举报

发表于 2007-5-16 14:37 | 显示全部楼层

回复 #1 insects 的帖子

能不展开就好还是不要展开的好,ode45对于通常的含有正弦余弦的函数还是可以求解的
发表于 2007-5-17 07:58 | 显示全部楼层
无需展开
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-6-2 15:46 , Processed in 0.116265 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表