matlab如何得到伪随机序列?
发布网友
发布时间:2022-04-25 00:02
我来回答
共2个回答
热心网友
时间:2023-10-16 09:36
% 小数开方伪随机数发生器 randmtx = randUI(10, 10, 10000, 0, 1)
% row 伪随机数矩阵的行数
% col 伪随机数矩阵的列数
% seed 种子
% k1, k2 生成的伪随机数的范围
function randmtx = randU2(row, col, seed, k1, k2)
if nargin < 3
seed = 11;
end
m = 4;
seed2 = sqrt(seed);
while seed2 < 1
seed2 = seed2 * 10;
end
n = round(seed2/m);% 返回最接近seed2/m的整数
x = (10^n)*seed2;
randmtx(1,1) = x - floor(x);
for i = 2:row*col
temp = sqrt(abs(randmtx(1,i-1)));
if temp == 0
temp = eps;
end
while temp < 1
temp = temp * 10;
end
n = round(temp/m);
x = (10^n)*temp;
randmtx(1,i) = (x - floor(x));
end
randmtx = reshape(randmtx, row, col);
if nargin < 4
return
end
randmtx = randmtx * (k2 - k1) + k1;
热心网友
时间:2023-10-16 09:36
m序列可以通过matlab产生,也可以通过simulink仿真实现