声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1685|回复: 6

[应用数学] 高手们帮忙看下!

[复制链接]
发表于 2008-4-20 17:34 | 显示全部楼层 |阅读模式

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

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

x
function xdot=wf(t,x)
syms x y z u v
a='-1.5*x-x^5*y-2*x*y*z-x*y';
da(1)=diff(a,x);
da(2)=diff(a,y);
da(3)=diff(a,z);
q=x^6+2*x^2*z+x^2-0.001*y+(u-a)^2*((1+(da(1))^2)*(2*z+1)+(x^2+u^2)^2+((da(1))*x^2)^2);
g=-2*(u-a)+(da(1))*u+0.5*(da(2))*q+(da(3))*z-y*(u-a)*(1+(da(1))^2)*(2*z+1)-y*(u-a)*((x^2+u^2)^2+((da(1))^2*x^2)^2);
%dx/dt=u+x^2*sin(2*x)+2*v*sin(x)+0.5*x*sint
%dy/dt=0.5*q
%dz/dt=-z+x^4+0.625
%du/dt=g+5*x+(6*u^2)/(1+2*x^2)+(1-cosu)*v+0.5*x*cost
%dv/dt=-v+x^2+0.5
x=zeros(5,1)
dx(1)=x(4)+x(1)^2*sin(2*x(1))+2*x(5)*sin(x(1))+0.5*x(1)*sint;
dx(2)=0.5*q;
dx(3)=-x(3)+x(1)^4+0.625;
dx(4)=g+5*x(1)+(6*x(4)^2)/(1+2*x(1)^2)+(1-cosx(4))*x(5)+0.5*x(1)*cost;
dx(5)=-x(5)+x(1)^2+0.5;
t0=0;tf=2;x0=[1,1,1,1,1]';
[t,x]=ode23('wf',t0,tf,x0);
plot(t,x);
figure(2)
plot(x(:,1))

为什么会出现这样的错误:Input argument "TotalBits" is undefined.
之后把sint,cost去掉后,
错误为:The following error occurred converting from sym to double:
Error using ==> sym.double
DOUBLE cannot convert the input expression into a double array.
If the input expression contains a symbolic variable, use the VPA function instead.
谢谢!
回复
分享到:

使用道具 举报

发表于 2008-4-20 19:17 | 显示全部楼层
syms x y z u v
这个,m函数里面最好不要定义符号变量
发表于 2008-4-20 22:26 | 显示全部楼层

回复 楼主 的帖子

奇怪的问题,里面怎么还有微分呢?
 楼主| 发表于 2008-4-24 19:05 | 显示全部楼层
那如果我要对符号变量求微分,怎么办好呢?
谢谢!
发表于 2008-4-24 21:12 | 显示全部楼层
dx(1)=x(4)+x(1)^2*sin(2*x(1))+2*x(5)*sin(x(1))+0.5*x(1)*sint;
dx(2)=0.5*q;
dx(3)=-x(3)+x(1)^4+0.625;
dx(4)=g+5*x(1)+(6*x(4)^2)/(1+2*x(1)^2)+(1-cosx(4))*x(5)+0.5*x(1)*cost;


里面的sintcost,都要改成sin(t) cos(t)
发表于 2008-4-24 21:13 | 显示全部楼层
把微分表示成具体形式再编程
这程序看的我一阵糊涂,使劲想,不难,但是有的混乱,你把意思表示明白吧
发表于 2008-4-24 22:12 | 显示全部楼层

回复 6楼 的帖子

cost 是什么?

在matlab里面没有这个函数,要写成sin(t)
你要看一下matlab 的基本语法结构方面的书
您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

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

GMT+8, 2024-5-17 03:32 , Processed in 0.053413 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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