"Sprand" problem

1 次查看(过去 30 天)
Atta Oveisi
Atta Oveisi 2012-4-26
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?

回答(1 个)

Wayne King
Wayne King 2012-4-26
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.

类别

Help CenterFile Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by