Replacing values in a matrix with random normally distributed value?

Hi, So I have 10x10matrix; A=[]
25 25 25 25 25 15 20 20 10 10
20 10 25 20 20 20 15 20 20 10
20 15 25 20 20 20 15 15 20 15
20 20 10 20 20 20 15 15 20 15
15 25 25 20 20 20 15 15 10 15
10 25 25 20 20 20 15 15 10 15
15 15 15 20 20 10 15 15 10 20
20 25 15 15 15 10 10 10 10 20
25 15 15 10 15 10 20 20 20 20
15 15 10 10 15 15 15 15 15 15.
Is there a way for me to replace all the
  • 10's with a normally distributed random values between 0.02-0.03
  • 15's with a normally distributed random values between 0.02-0.04
  • 20's with a normally distributed random values between 0.03-0.05
  • 25's with a normally distributed random values between 0.10-0.20
Cheers, Jim

回答 (1 件)

Walter Roberson
Walter Roberson 2016 年 8 月 15 日

0 投票

mask = A == 10;
A(mask) = 0.02 + 0.01 * rand( 1, nnz(mask) );

タグ

質問済み:

Jim
2016 年 8 月 15 日

回答済み:

2016 年 8 月 15 日

Community Treasure Hunt

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

Start Hunting!

Translated by