参考代码
N=3000;
x=zeros(N+1,1);
y=x;
clf
for i=1:N
x(i+1)=1+y(i)-1.4*x(i)^2;
y(i+1)=0.3*x(i);
end
plot(x,y,'.')
title(['x_{k+1} = 1+y_k+1.4*x_k^2' 10 'y_{k+1} = 0.3x_k']);
xlabel('x');
ylabel('y');
绘图结果
下面的代码加入了动态效果,你试一试,看值不值得追加:
N=3000;
x=[0; zeros(N,1)*NaN];
y=x;
clf
tail = plot(x,y,'.','color',[1 1 1]*0.75,'markersize',5);
hold on
head = plot(NaN,NaN,'.','markersize',25);
title(['x_{k+1} = 1+y_k+1.4*x_k^2' 10 'y_{k+1} = 0.3x_k']);
xlabel('x');
ylabel('y');
for i=1:N
x(i+1)=1+y(i)-1.4*x(i)^2;
y(i+1)=0.3*x(i);
try
set(tail,'xData',x,'yData',y)
set(head,'xData',x(i+1),'yData',y(i+1))
drawnow
catch
break
end
end