如何在 MATLAB 上绘制相邻数据点

How do I plot neighboring data points against each other on MATLAB

我目前正在做一个项目来改进后勤地图以创建 PRNG。 我试图证明从我的代码生成的数据在针对相邻数据点绘制时彼此之间具有相关性,并尝试在图表上显示它。

这是我的代码,如下所示。它为 500 次迭代生成不同的数据点。

    x = rand(1);
    r = 3.99;

    for i = 1:500
    for j = 1:1
    
    X1(i,j) = r*x*(1-x);
    %for next iteration
    x = X1(i,j); 
    
    end
    end

    %output
    disp(X1);
    plot(X1);

不确定这是否是您想要绘制的,但这里是 X1 针对它的相邻值(shifted-self)绘制的。每个值都绘制为坐标对 (X1[n],X1[n+1]),其中 n 是从 n=1499 的索引值 运行。这导致了一个看起来有趣且有前途的曲线图。索引时我使用 end 指定向量的最后一个索引 X1.

X1(1:end-1) → 从索引 1 到 499
X1(2:end) → 从索引 2 到 500

其中,end = numel(X1)(元素数量)和 length(x1) 在这种情况下。

x = rand(1);
r = 3.99;
X1 = zeros(500,1);

for i = 1:500
for j = 1:1

    X1(i,j) = r*x*(1-x);

    %For next iteration%
    x = X1(i,j); 

end
end

disp(X1);
plot(X1(1:end-1),X1(2:end),'.');
title("Plotting Against Neighbouring Value");
xlabel("X1[n]"); ylabel("X1[n+1]");