Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
while running following snippet matlab code

file_name='B.bmp';
key=double(imread(file_name))./256;

rand('state',key);


following error was thrown by matlab:
??? Error using ==> rand
State must be a double scalar.


can anyone please help me on this i am new to matlab.
Posted
Updated 1-Apr-12 6:37am
v2
Comments
Sergey Alexandrovich Kryukov 1-Apr-12 13:05pm    
Wow! What was your idea behind the string 'state'? :-)
--SA

1 solution

This is explained here:
http://www.mathworks.com/help/techdoc/math/brnuahp.html[^],
http://www.mathworks.com/help/techdoc/math/bruv81b.html[^].

You are doing something weird: instead of passing two integers (please see the second of the pages referenced above, with samples), you pass the string 'state'. I cannot even imagine what did you mean by that… :-)

—SA
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900