Search code examples
matlabrandomneural-networkundefinedundefined-function

Undefined function or variable 'setdemorandstream'


I am working on a feed-forward neural network analysis using MATLAB. I am getting the following error:

Undefined function or variable 'setdemorandstream'.

Code is as follows:

setdemorandstream(391418381);

Any help in rectifying this error is appreciated.


Solution

  • These are the contents of the function, verbatim:

    function setdemorandstream(n)
    %SETDEMORANDOMSTREAM Set default stream for reliable example results.
    %
    %  SETDEMORANDOMSTREAM(N) is less distracting in example code, but
    %  equivalent to:
    %
    %    rs = RandStream('mcg16807','Seed',n);
    %    RandStream.setGlobalStream(rs);
    
    % Copyright 2011-2012 The MathWorks, Inc.
    
    rs = RandStream('mcg16807','Seed',n);
    RandStream.setGlobalStream(rs);
    

    Just save this as a file in your MATLAB path.

    However, your errors might not stop there - make sure you have the neural network toolbox installed.