function x=getx(net)
%GETX Get all network weight and bias values as a single vector.
%
%	Syntax
%
%	  X = getx(net)
%
%	Warning!!
%
%	  This function may be altered or removed in future
%	  releases of the Neural Network Toolbox. We recommend
%	  you do not write code which calls this function.
%
%	See also SETX, FORMGX.

% Mark Beale, 11-31-97
% Copyright (c) 1992-1998 by The MathWorks, Inc.
% $Revision: 1.3 $

% Shortcuts
inputLearn = net.hint.inputLearn;
layerLearn = net.hint.layerLearn;
biasLearn = net.hint.biasLearn;
inputWeightInd = net.hint.inputWeightInd;
layerWeightInd = net.hint.layerWeightInd;
biasInd = net.hint.biasInd;

x = zeros(net.hint.xLen,1);
for i=1:net.numLayers
  for j=find(inputLearn(i,:))
    x(inputWeightInd{i,j}) = net.IW{i,j}(:);
  end
  for j=find(layerLearn(i,:))
    x(layerWeightInd{i,j}) = net.LW{i,j}(:);
  end
  if biasLearn(i)
    x(biasInd{i}) = net.b{i};
  end
end
