| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1079 人关注过本帖
标题:微分方程错误..Error using ==> feval
只看楼主 加入收藏
慢跑20
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2013-4-23
结帖率:0
收藏
 问题点数:0 回复次数:1 
微分方程错误..Error using ==> feval
课本传染病模型SIR.
先建立M文件
function y=ill(t,x)
a=1;b=0.3;
y=[a*x(1)*x(2)-b*x(1),-a*x(1)*x(2)]';
然后再MATLAB中输入:
ts=0:50;
x0=[0.02,0.98];
[t,x]=ode45('ill',ts,x0);[t,x]
Plot(t,x(:1,),t,x(:,2)),grid,pause
Plot(x(:,2),x(:,1)),grid
function y=ill(t,x)
a=1;b=0.3;
y=[a*x(1)*x(2)-b*x(1),-a*x(1)*x(2)]';

就会:
显示错误:
如下:
??? Error using ==> feval
Undefined command/function 'ill'.

Error in ==> funfun\private\odearguments at 110
f0 = feval(ode,t0,y0,args{:});   % ODE15I sets args{1} to yp0.

Error in ==> ode45 at 173
[neq, tspan, ntspan, next, t0, tfinal, tdir, y0, f0, odeArgs, ...

>>
啥问题呢?
搜索更多相关主题的帖子: command 传染病 function private 
2013-05-11 17:17
cuijunchao
Rank: 5Rank: 5
来 自:湖南桂东
等 级:职业侠客
威 望:3
帖 子:132
专家分:386
注 册:2012-4-4
收藏
得分:0 
function [ dy ] =ill( t,x )
 dy(1)=0;
 dy(2)=0;
 a=1;b=0.3;
 dy=[a*x(1)*x(2)-b*x(1),-a*x(1)*x(2)]';
end

ts=0:1:50;
 x0=[0.02 0.98];
 [t,x]=ode45('ill',ts,x0);

 plot(ts,x(:,1)),grid
这样是可以了 数据你添上去吧
2013-05-12 13:33
快速回复:微分方程错误..Error using ==> feval
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016815 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved