How to generate random numbers between -pi and pi

14 vues (au cours des 30 derniers jours)
Jelthe
Jelthe le 8 Avr 2016
Commenté : Jelthe le 8 Avr 2016
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

Réponse acceptée

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

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Creating and Concatenating Matrices dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by