Matlab command for generating random rational numbers between -1 and 0?

2 vues (au cours des 30 derniers jours)
sara
sara le 18 Août 2014
Commenté : Johan Löfberg le 19 Août 2014
Anyone knows that how can I generate rational numbers between -1 and 0?

Réponse acceptée

Adam
Adam le 18 Août 2014
  8 commentaires
Adam
Adam le 18 Août 2014
Sorry, I've never heard of it
Johan Löfberg
Johan Löfberg le 19 Août 2014
What does YALMIP have to do with this question? Post your YALMIP questions on https://groups.google.com/forum/?fromgroups=#!forum/yalmip

Connectez-vous pour commenter.

Plus de réponses (1)

Ben11
Ben11 le 18 Août 2014
Modifié(e) : Ben11 le 18 Août 2014
Like this?
a = -1;
b = 0;
r = a+(b-a)*rand(1,1)
If you want many of them change the inputs to rand. And if you want the fractional representation, use rats(r).

Catégories

En savoir plus sur Loops and Conditional Statements 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