How to add +- 10 to particular values randamly

2 ビュー (過去 30 日間)
Fire
Fire 2011 年 6 月 8 日
Dear all,
lets say I have the value of 1e6 and 5e6. I want to add + or - 10% of this value all the time. I mean
1e6+10%
5e6-10%
1e6-10%
5e6+10%
May be it can be random. Previously I assumed like
(rand(1,11)) + 1e6;
(rand(1,11))+ 5e6;
But it just give like rand numbers of 0.1 to 0.9 but I want in percentage as mentioned abover.
Can someone reply me quickly

採用された回答

the cyclist
the cyclist 2011 年 6 月 8 日
Homework? This might be right:
>> x = x .* (1 + 0.2*(rand(size(x))-0.5));
  1 件のコメント
Fire
Fire 2011 年 6 月 8 日
well Cyclist thanks for your answer.. It's not the homework since I am a naive in matlab, these simple things seems to difficult for me... This is wat im expecting.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by