【问题标题】:How do I plot neighboring data points against each other on MATLAB如何在 MATLAB 上绘制相邻数据点
【发布时间】:2021-03-29 18:15:42
【问题描述】:

我目前正在做一个项目来改进逻辑图以创建 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);

【问题讨论】:

    标签: matlab random matlab-figure


    【解决方案1】:

    不完全确定这是否是您想要绘制的,但这里是 X1 根据它的相邻值(移位自我)绘制的。每个值都绘制为坐标对 (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]");
    

    【讨论】:

    • 是的,这正是我需要的,即表明相邻点之间存在相关性。非常感谢。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-08-24
    • 1970-01-01
    • 2014-09-06
    相关资源
    最近更新 更多