How to generate random numbers between -pi and pi

15 ビュー (過去 30 日間)
Jelthe
Jelthe 2016 年 4 月 8 日
コメント済み: Jelthe 2016 年 4 月 8 日
Hi,
i tried generating numbers with linspace(-pi,pi) and i get somewhat the correct numbers. But only for the first run of course. I need random values between -pi and pi for several runs, and all should be other numbers. the rand() function doesnt work with pi

採用された回答

dpb
dpb 2016 年 4 月 8 日
help rand
...
Example 1: Generate values from the uniform distribution on the interval [a, b].
r = a + (b-a).*rand(100,1);
  1 件のコメント
Jelthe
Jelthe 2016 年 4 月 8 日
woops. sorry. i should really try before asking. but thank you it worked!

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

その他の回答 (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