物流图不正确 (Matlab)
Logistic map plot is incorrect (Matlab)
我正在尝试迭代并绘制 Logistic map nonlinear function given by the equation: x[n+1] = 4*x[n]*(1-x[n])
. I have found an implementation of the function here https://www.mathworks.com/matlabcentral/answers/122101-plotting-f-x-as-a-function-of-x-logistic-map
我遵循的是同样的事情,只是点数 N
和开始的初始条件在我的实现中不同。我不知道为什么我在输出中没有得到任何值;大多数是零值。当初始条件为 x[1] = 0.5
时,我得到如图所示的奇怪情节。但是当初始条件为 0.3 时,我就会得到正确的 Logistic 图。理论上,初始条件可以是0到1之间的任意数。那么,为什么当初始条件为0.5时代码不起作用?
有什么问题?
N=20000; % number of data points
x = zeros(1,N);
x(1) = 0.5; % initial condition (can be anything from 0 to 1)
for n = 1:N
x(n+1) = 4*x(n)*(1-x(n));
end
plot(x(1:N),x(2:N+1),'rs-')
xlabel('x_n')
ylabel('x_{n+1}')
这是情节
您得到的结果是正确的。下面我用蛛网图来解释一下(来源:http://sites.saintmarys.edu/%7Esbroad/example-logistic-cobweb.html)
抛物线是曲线y = 4*x*(1-x)
,蓝色的线性曲线是y=x
。点x[n]
的确定方式如下:
- 从点
(x0,y(x0))
开始(通常画有 (x0,0)
的线)
- 水平移动直到达到线性曲线
- 垂直移动直到碰到抛物线。这是你的
x[n+1]
.
- 重复步骤 2-3 直到无穷大或
x[n]=x[n-1]
(稳定点)或 x[n]=x[n-m]
(周期性)
注意稳定点是抛物线和线性曲线相交的地方。
将此方法应用于您的参数得到:
- 开始于
(0.5,1)
- 横向到
(1,1)
- 垂直
(1,0)
(这是 x[1]
)
- 横向到
(0,0)
- 垂直
(0,0)
(这是x[2]
)
- 横向到
(0,0)
- 垂直
(0,0)
(这是x[3]
)
- 停止
所以你恰好结束了稳定点。
我正在尝试迭代并绘制 Logistic map nonlinear function given by the equation: x[n+1] = 4*x[n]*(1-x[n])
. I have found an implementation of the function here https://www.mathworks.com/matlabcentral/answers/122101-plotting-f-x-as-a-function-of-x-logistic-map
我遵循的是同样的事情,只是点数 N
和开始的初始条件在我的实现中不同。我不知道为什么我在输出中没有得到任何值;大多数是零值。当初始条件为 x[1] = 0.5
时,我得到如图所示的奇怪情节。但是当初始条件为 0.3 时,我就会得到正确的 Logistic 图。理论上,初始条件可以是0到1之间的任意数。那么,为什么当初始条件为0.5时代码不起作用?
有什么问题?
N=20000; % number of data points
x = zeros(1,N);
x(1) = 0.5; % initial condition (can be anything from 0 to 1)
for n = 1:N
x(n+1) = 4*x(n)*(1-x(n));
end
plot(x(1:N),x(2:N+1),'rs-')
xlabel('x_n')
ylabel('x_{n+1}')
这是情节
您得到的结果是正确的。下面我用蛛网图来解释一下(来源:http://sites.saintmarys.edu/%7Esbroad/example-logistic-cobweb.html)
抛物线是曲线y = 4*x*(1-x)
,蓝色的线性曲线是y=x
。点x[n]
的确定方式如下:
- 从点
(x0,y(x0))
开始(通常画有(x0,0)
的线) - 水平移动直到达到线性曲线
- 垂直移动直到碰到抛物线。这是你的
x[n+1]
. - 重复步骤 2-3 直到无穷大或
x[n]=x[n-1]
(稳定点)或x[n]=x[n-m]
(周期性)
注意稳定点是抛物线和线性曲线相交的地方。
将此方法应用于您的参数得到:
- 开始于
(0.5,1)
- 横向到
(1,1)
- 垂直
(1,0)
(这是x[1]
) - 横向到
(0,0)
- 垂直
(0,0)
(这是x[2]
) - 横向到
(0,0)
- 垂直
(0,0)
(这是x[3]
) - 停止
所以你恰好结束了稳定点。