%
%LQGOPT1 Function to optimize LQG example using least squares
%
%	See the file LQGCOST to see how the cost function is derived.

%	Copyright (c) 1990-94 by The MathWorks, Inc.

% Load data for model
if ~exist('a')
	lqgdata
end
% Open scope
open_system('lqgopt/Scope')

% Initial guesses at feedforward gain
FF = 1;

% Initial guess at state-feedback gain matrix (from LQR design)
K = [-1.13,1.07,-0.00291,-0.433,0];

% Set optimization parameters
options = [1,0.2,0.2]; % set display and termination criteria
x = leastsq('lqgcost', [K,FF], options);

