求帮忙写一下用MATLAB7.0解微分方程的编程

方程是:d^2x/dt^2=1/(y^2+x^2)*cos(arctan(y/x))
d^2y/dt^2=1/(y^2+x^2)*sin(arctan(y/x))
x、y是关于t的函数
P.S.当x=0时,dx/dt=1,dy/dt=0
求程序或线素场或公式解
P.S.应该有一个解是x=sin(x),y=cos(x)

function dx=myfun(t,x)
dx=zeros(4,1);
dx(1)=x(2);
dx(2)=1/(x(1)^2+x(3)^2)*cos(atan(x(3)/x(1)));
dx(3)=x(4);
dx(4)=1/(x(1)^2+x(3)^2)*sin(atan(x(3)/x(1)));

clc
clear
options=odeset('reltol',1e-8);
x0=[0;1;1;0];
[t,y]=ode45(@myfun,[0,1],x0,options)
plot(y(:,1),y(:,3));
我没运行,直接写的,你试试看吧,大体这个思路
温馨提示:答案为网友推荐,仅供参考
第1个回答  2014-07-26
求解数值解还是解析解?追问

数值解

追答

编程的话可以尝试用ode45函数求解

追问

能帮我写一下吗

相似回答