Creating random error numbers within specified range.

12 ビュー (過去 30 日間)
Mr.Chandler
Mr.Chandler 2020 年 11 月 9 日
コメント済み: Mr.Chandler 2020 年 11 月 9 日
Here is a table which length is 100cm. I have to measure it 100 times 1000 times and 1 million times. In each calculation there should be random error in + or -. And errror should be between 1mm and 10mm. And I have to create plots of 100times 1000times and 1 million times. How can I write that code? Our teacher recommended "randn". However, I can't create numbers between (+ -) 1 and 10.

採用された回答

Mathieu NOE
Mathieu NOE 2020 年 11 月 9 日
Example 1: Generate values from the uniform distribution on the interval (a, b).
r = a + (b-a).*rand(100,1);
  3 件のコメント
Mathieu NOE
Mathieu NOE 2020 年 11 月 9 日
well, then you shoud create two stes of random numbers , one in the -10 to -1 range and the second in the 1 to 10 range and merge the two vectors in one
Mr.Chandler
Mr.Chandler 2020 年 11 月 9 日
Yes, I tried that way and it works. Thanks so much.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by