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

3 visualizzazioni (ultimi 30 giorni)
Anyone knows that how can I generate rational numbers between -1 and 0?

Risposta accettata

Adam
Adam il 18 Ago 2014
  8 Commenti
Johan Löfberg
Johan Löfberg il 19 Ago 2014
What does YALMIP have to do with this question? Post your YALMIP questions on https://groups.google.com/forum/?fromgroups=#!forum/yalmip

Accedi per commentare.

Più risposte (1)

Ben11
Ben11 il 18 Ago 2014
Modificato: Ben11 il 18 Ago 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).

Categorie

Scopri di più su Loops and Conditional Statements 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