"Sprand" problem

1 Ansicht (letzte 30 Tage)
Atta Oveisi
Atta Oveisi am 26 Apr. 2012
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?

Antworten (1)

Wayne King
Wayne King am 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.

Kategorien

Mehr zu Creating and Concatenating Matrices finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by