%% Get Current Values of Gain Surface Coefficients
% Extract the current coefficient values from a tunable gain surface K = K_{0} + K_{1}\alpha + K_{2}\alpha^{2}.
% For this example, create a tunable gain surface and extract the initial values of its coefficients. Generally, gainsurfdata is useful for extracting tuned coefficient values after control system tuning with systune.
% Create the tunable gain surface.

alpha = 0:10:100;
F1 = alpha;
F2 = alpha.^2;
K = gainsurf('K',1,F1,F2)

% K is a generalized matrix (genmat) with tunable coefficients K_0, K_1, K_2.
%
% Extract the current values of the tunable coefficients.

[K0,K1,K2] = gainsurfdata(K)

% You specify the initial value of K_0 with the K0init input argument to gainsurf. The output of gainsurfdata shows that gainsurf automatically assigns initial values of 0 to the remaining coefficients.
% Copyright 2015 The MathWorks, Inc.