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

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

 Risposta accettata

zheyson
zheyson il 28 Ott 2022

0 voti

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 是正态分布。

Più risposte (0)

Tag

Richiesto:

il 28 Ott 2022

Risposto:

il 28 Ott 2022

Community Treasure Hunt

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

Start Hunting!