フィルターのクリア

How can I add a random error to many elements in a matrix?

5 ビュー (過去 30 日間)
Alex Saoulis
Alex Saoulis 2016 年 11 月 26 日
コメント済み: Star Strider 2016 年 11 月 26 日
Hi, I have a matrix of values calculated from a polynomial. I also have a Gaussian error function,
r1 = rand();
r2 = rand();
g = sqrt(-2*log(r1))*cos(2*pi*r2)
I would like my function to then calculate and add different values of g to each of the n elements in the matrix. Could anyone point me in the right direction?

採用された回答

Star Strider
Star Strider 2016 年 11 月 26 日
See if this does what you want:
M = randi(9, 3, 4); % Matrix (Integers)
r1 = rand(size(M,1),1);
r2 = rand(1,size(M,2));
g = sqrt(-2*log(r1))*cos(2*pi*r2);
M_With_Noise = M + g;
I’m guessing at how to work with your ‘g’ function. This seems to work.
  2 件のコメント
Alex Saoulis
Alex Saoulis 2016 年 11 月 26 日
This seems to work! Thanks a lot!
Star Strider
Star Strider 2016 年 11 月 26 日
My pleasure!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by