Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB: sparse matrices in matlab anamoly?

  1. Jul 2, 2012 #1
    In MATLAB, Why is sparse(rand(4)) not same as sprand(4)? Is it not supposed to be? What is the reason? Please see the interaction in MATLAB pasted below.

    sprand(4)

    ans =

    (1,1) 0.8147

    >> rand(4)

    ans =

    0.9058 0.0975 0.9649 0.4854
    0.1270 0.2785 0.1576 0.8003
    0.9134 0.5469 0.9706 0.1419
    0.6324 0.9575 0.9572 0.4218

    >> sparse(ans)

    ans =

    (1,1) 0.9058
    (2,1) 0.1270
    (3,1) 0.9134
    (4,1) 0.6324
    (1,2) 0.0975
    (2,2) 0.2785
    (3,2) 0.5469
    (4,2) 0.9575
    (1,3) 0.9649
    (2,3) 0.1576
    (3,3) 0.9706
    (4,3) 0.9572
    (1,4) 0.4854
    (2,4) 0.8003
    (3,4) 0.1419
    (4,4) 0.4218
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: MATLAB: sparse matrices in matlab anamoly?
  1. Matrices in Matlab (Replies: 5)

  2. Matrices in matlab (Replies: 2)

Loading...