creating matrix of 1 nd -1
Ältere Kommentare anzeigen
how can i generate random matrix of 1 and -1 ...
thanks in advance
2 Kommentare
Thomas
am 21 Mär. 2012
Do you want the elements of the matrix to be only 1 and -1 or between 1 and -1
umar siyab
am 21 Mär. 2012
Antworten (2)
Jan
am 21 Mär. 2012
1 and -1:
x = 1 - (rand(3,5) > 0.5) *2;
From -1 to 1:
x = 1 - rand(3,5) *2;
1 Kommentar
umar siyab
am 21 Mär. 2012
David Young
am 21 Mär. 2012
Assuming that you want values of 1 and -1 only, you can do
2*randi(2, m, n) - 3
1 Kommentar
umar siyab
am 21 Mär. 2012
Kategorien
Mehr zu Random Number Generation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!