如何统计矩阵中的数据​并将超出一定范围的数​据归到边界。

z=rand(100,100);
依据统计中的拉依达准则3σ,将矩阵中超出(μ-2σ,μ+2σ)的元素的值归到边界值域。
该怎么写这样的代码?

 采纳的回答

zheyson
zheyson 2022-10-28

0 个投票

z=randn(100,100);
zmax=max(z(:));
zmin=min(z(:));
zavg=mean(z(:))
sigma=std(z(:));
z(z>zavg+2*sigma)=zmax;
z(z<zavg-2*sigma)=zmin;
mean(z(:))
用rand没意义,它是均匀分布的取值0~1,randn 是正态分布。

更多回答(0 个)

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!