回 帖 发 新 帖 刷新版面

主题:真诚求助,帮我改下错误的程序

function predatorPrey(h, length, OldX, OldY, plotStateSpace, r1, b1, r2, b2, c, timedelay) NumTimeSteps = length / h;
pref ill = timedelay/h;
for i = 1:1+pref ill;
XStor(i) = OldX;
YStor(i) = OldY; 
end;
for s = prefill+2:NumTimeSteps
[x,y] = growth(XStor(s-1), XStor(s - 1 - timedelay/h),
YStor(s-1), YStor(s - 1 - timedelay/h), h, r1, b1, r2, b2, c); 
XStor(s) = x;
YStor(s) = y;
T(s) = s*h; 
end;
plot (0);
axis("on");
legend("off");
if (! plotStateSpace)
ylabel("Population Size"); xlabel("Time");
hold on;
plot(T, XStor, ’b;;’);
plot(T, YStor, ’r;;’);
hold off;
else
ylabel("Predator");
           xlabel("Prey");
hold on;
plot(XStor, YStor, ’b;;’);
hold off;
end;
function [x,y] = growth(OldX, OlderX, OldY, OlderY, h, r1, b1, r2, b2, c)
x = OldX + h *(r1 * OlderX - (r1/c) * OldX * OldX - b1 * OldX * OldY);
y = OldY + h *(b2 * OldX * OldY - r2 * OldY);

错误信息是
??? function predatorPrey(h, length, OldX, OldY, plotStateSpace, r1, b1, r2, b2, c, timedelay) NumTimeSteps = length / h;
                                                                                               |
Error: Missing operator, comma, or semicolon

回复列表 (共6个回复)

沙发

你的
function predatorPrey(h, length, OldX, OldY, plotStateSpace, r1, b1, r2, b2, c, timedelay) NumTimeSteps = length / h;
是一行把,M文件第一行是有讲究的,不能加分号,换行了要加换行号...而且,函数文件最好使用
function yy=predatorPrey(h, length, OldX, OldY, plotStateSpace, r1, b1, r2, b2, c, timedelay) (写成一行)
NumTimeSteps = length / h;

板凳

我安你说的试了还是不行啊,急死了,还有什么注意吗?

3 楼

错误的信息都一样的

4 楼

今天才来看贴!sorry!
请你把原程序按你的M文件中的顺序写清楚,错误信息是误用了标点, ;
标点不能有中文字符

5 楼

写好了请通知我QQ402868140

6 楼

请帖程序!!!

我来回复

您尚未登录,请登录后再回复。点此登录或注册