a short code for creating a random (1,-1) matrix

This is a very short code file for creating a random matrix whose entries are either 1 or -1.
405 Downloads
Updated 15 May 2010

View License

I have no idea whether this is the first one, but I am pretty sure that you guys can fully understand what can be done by this short and concise matlab code, that is, to generate a random matrix of any given order, with entries randomly chosen from {1,-1}. In fact, the code can be extended to produce any random matrix whose elements are randomly chosen from any dyadic set ,say, {a,b}. The work was originated and inspired by the blog of Terence Tao on random matrix (see the webpage:
http://terrytao.wordpress.com/tag/random-matrices/)
and a talk "Discrete random matrices " by P.M.Wood from Stanford on the BADMath day of Spring 2010, San Jose,CA.
The running of the code is very fast, as you can find. But it will sharply slow down and display "inf" on your command window if you
put "det" function involved to test its singularity. Sure we may avoid this by using instead a logic function.

Cite As

Changqing Xu (2024). a short code for creating a random (1,-1) matrix (https://www.mathworks.com/matlabcentral/fileexchange/27622-a-short-code-for-creating-a-random-1-1-matrix), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Linear Algebra in Help Center and MATLAB Answers

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.0.0.0