作业帮 > 综合 > 作业

如何在matlab上产生一个均匀分布的x

来源:学生作业帮 编辑:作业帮 分类:综合作业 时间:2024/05/15 01:57:42
如何在matlab上产生一个均匀分布的x
如何在matlab上产生一个服从均匀分布的x,并且属于[-1,1] ,并且产生100次
你只需下列的第一,第四行.你可设N=100.
function Theorem1(N,a)
% N:Number of observed samples
% a:true value of a
Vi = randn([1,N+1]); % Normally distributed random numbers.chosen from a normal distribution with mean zero,variance one and standard deviation one.
Xi = [1:N+1]*0; % X(Nx1) vector with initial values set to zero
%compute Xi+1 = a*Xi + Vi+1
for i=1:N
Xi(i+1) = a*Xi(i) + Vi(i+1);
end
%compute the estimated a