Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Random Matrix help
Replies: 3   Last Post: May 6, 2013 2:40 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Hend

Posts: 1
Registered: 5/6/13
Random Matrix help
Posted: May 6, 2013 12:27 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

I've never done any programming before so excuse me if what I'm asking is too simple to even be asked. I'm trying to construct a random nxn matrix that is symmetric and has entries of either 1 or -1 on the off-diagonals and 0s on the diagonal. Something tells me this is really easy but I can't figure it out.

I have this so far

n=5;
A=rand(n);
A=(A+A')/2;
round(A)

But this only gives me entries of either 0 or 1 and I cannot figure out what to do to make the entries on the diagonal 0s.

Thanks.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.