"Sprand" problem
2 views (last 30 days)
Show older comments
I use MATLAB Version 7.8.0.347 (R2009a)
I want to use the "sprand" command, but when I use this two commands below I get conflicting answers.
this one works well:
sprand(100,50,0.1,1e-2);
but this one says that there is an error: sprand(100,50,0.01,1e-2); ??? Error using ==> rand Size vector must be a row vector with real elements.
Error in ==> sprand at 39 i = fix( rand(nnzwanted, 1) * m ) + 1;
Error in ==> sprand at 122 ak = sprand(m,1, nzpc/m);
I am confused. What is the problem?
0 Comments
Answers (1)
Wayne King
on 26 Apr 2012
Hi Atta, I think perhaps you have some non-MathWorks function on your path that precedes the MathWorks' version. That line should work in R2009a.
If you enter
>>which rand
Do you get something like the following?
built-in (.../toolbox/matlab/randfun/rand)
Perhaps you have another version of rand() in your installation?
If
>>which rand
does not return the above, either remove the other file from your path, or remove the folder it is located in.
0 Comments
See Also
Categories
Find more on Creating and Concatenating Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!