How to generate random numbers between -pi and pi

18 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

dpb
dpb il 8 Apr 2016
help rand
...
Example 1: Generate values from the uniform distribution on the interval [a, b].
r = a + (b-a).*rand(100,1);
  1 Commento
Jelthe
Jelthe il 8 Apr 2016
woops. sorry. i should really try before asking. but thank you it worked!

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Creating and Concatenating Matrices in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by