[英]How do I plot neighboring data points against each other on MATLAB
我目前正在做一個項目來改進后勤 map 以創建 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);
不完全確定這是否是您想要的 plot 但這里是X1
相對於它的相鄰值(移位自我)繪制的。 每個值都繪制為坐標對( X1[n]
, X1[n+1]
),其中n
是從n=1
到499
的索引值。 這導致彎曲的 plot 看起來很有趣且很有希望。 索引時,我使用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]");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.