Matlab 版 (精华区)
发信人: hahn (有奇@选择遗忘的自由), 信区: Matlab
标 题: [合集] 求助!
发信站: 哈工大紫丁香 (Sun Aug 6 09:07:55 2006), 站内
────────────────────────────────────────
Lavic (lavic) 于 (Sat May 20 15:49:42 2006) 说道:
在使用matlab中ode解微分方程时,系统提示描述微分方程的函数有错误:Input argum
ent "x" is undefined.
但是我用老师的程序调用微分方程的函数是却能运行,不知道是什么原因,向各位高手
请教,小弟这厢有礼了!
────────────────────────────────────────
zjliu (秋天的萝卜) 于 (Sat May 20 15:50:22 2006) 说道:
能贴一下你写的函数么
【 在 Lavic (lavic) 的大作中提到: 】
: 在使用matlab中ode解微分方程时,系统提示描述微分方程的函数有错误:Input argum
: ent "x" is undefined.
: 但是我用老师的程序调用微分方程的函数是却能运行,不知道是什么原因,向各位高手
: ...................
────────────────────────────────────────
Lavic (lavic) 于 (Sat May 20 15:57:14 2006) 说道:
【 在 zjliu (秋天的萝卜) 的大作中提到: 】
: 能贴一下你写的函数么
微分方程描述函数:
function xdot=lafun(t,x)
dx=zeros(2,1);
dx(1)=x(2);
dx(2)=-x(1)*cos(t);
ode函数
[t,tx]=ode23(fun,xspan,y0);
其中:xspan=input('请输入求解自变量区间:');
y0=input('请输入初始值:');
────────────────────────────────────────
zjliu (秋天的萝卜) 于 (Sat May 20 16:08:26 2006) 说道:
这样试试:
微分方程描述函数:
function xdot=lafun(t,x)
xdot=[x(2);-x(1)*cos(t)];
%dx=zeros(2,1);
%dx(1)=x(2);
%dx(2)=-x(1)*cos(t);
ode函数
[t,tx]=ode23(lafun,xspan,y0);
其中:xspan=input('请输入求解自变量区间:');
y0=input('请输入初始值:');
【 在 Lavic (lavic) 的大作中提到: 】
: 微分方程描述函数:
: function xdot=lafun(t,x)
: dx=zeros(2,1);
: ...................
────────────────────────────────────────
Lavic (lavic) 于 (Sat May 20 16:13:47 2006) 说道:
【 在 zjliu (秋天的萝卜) 的大作中提到: 】
: 这样试试:
: 微分方程描述函数:
: function xdot=lafun(t,x)
: xdot=[x(2);-x(1)*cos(t)];
: %dx=zeros(2,1);
: %dx(1)=x(2);
: %dx(2)=-x(1)*cos(t);
: ode函数
: ...................
还是不行,不过仍然谢谢你
────────────────────────────────────────
zjliu (秋天的萝卜) 于 (Sat May 20 16:54:13 2006) 说道:
呵呵, 受不了了, 下面这样肯定行
fun=inline('[x(2);-x(1)*cos(t)]','t','x');
[t,tx]=ode23(fun,[0,10],[0.1,1]);
plot(t,tx)
【 在 Lavic (lavic) 的大作中提到: 】
: 还是不行,不过仍然谢谢你
Powered by KBS BBS 2.0 (http://dev.kcn.cn)
页面执行时间:3.925毫秒