Chaging the outupt integers
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have a code here
M=256;
N=256
A=fix(2*rand(M,N));
And right now the output either is zero or one. Well I want the output to be either 1 or -1. Can anyone help me as to how to change this. Thank you, I'm quite new to matlab.
0 commentaires
Réponse acceptée
Azzi Abdelmalek
le 25 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 25 Fév 2013
M=256;
N=256
A=fix(2*rand(M,N));
A(A==0)=-1
2 commentaires
Azzi Abdelmalek
le 25 Fév 2013
Modifié(e) : Azzi Abdelmalek
le 25 Fév 2013
You can also use
A=sign(rand(M,N)-0.5)
Plus de réponses (0)
Voir également
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!