永发信息网

在matlab中看瑞利分布

答案:2  悬赏:20  手机版
解决时间 2021-11-13 16:46
  • 提问者网友:树红树绿
  • 2021-11-12 17:42
在matlab中看瑞利分布
最佳答案
  • 五星知识达人网友:孤独的牧羊人
  • 2021-11-12 17:54
可以直接使用raylrnd计算瑞利分布比如r = raylrnd(1:5)得到r = 1.7986 0.8795 3.3473 8.9159 3.5182
全部回答
  • 1楼网友:梦中风几里
  • 2021-11-12 19:13
%----------Input Section----------------

N=1000000; %Number of samples to generate
variance = 1; % Variance of underlying Gaussian random variables
%---------------------------------------

%Independent Gaussian random variables with zero mean and unit variance

x = randn(1, N);
y = randn(1, N);

%Rayleigh fading envelope with the desired variance

r = sqrt(variance*(x.^2 + y.^2));

%Define bin steps and range for histogram plotting

step = 0.1; range = 0:step:5;

%Get histogram values and approximate it to get the pdf curve

h = hist(r, range);
approxPDF = h/(step*sum(h)); %Simulated PDF from the x and y samples

%Theoritical PDF from the Rayleigh Fading equation

theoretical = (range/variance).*exp(-range.^2/(2*variance));
plot(range, approxPDF,'b*', range, theoretical,'r');
title('方差1.0时瑞利概率密度函数仿真值和理论值')
legend('概率密度仿真值','概率密度函数理论值')
xlabel('r');
ylabel('P(r)');
grid;

%PDF of phase of the Rayleigh envelope

theta = atan(y./x);
figure(2)
hist(theta); %Plot histogram of the phase part
%Approximate the histogram of the phase part to a nice PDF curve

[counts,range] = hist(theta,100);
step=range(2)-range(1);
approxPDF = counts/(step*sum(counts)); %Simulated PDF from the x and y samples
bar(range, approxPDF,'b');
hold on
plotHandle=plot(range, approxPDF,'r');
set(plotHandle,'LineWidth',3.5);
axis([-2 2 0 max(approxPDF)+0.2])
hold off
title('瑞利概率密度函数相位分布仿真 ');
xlabel('\theta ');
ylabel('P(\theta)');
grid;
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯