www.gusucode.com > sloptim工具箱matlab源码程序 > sloptim/sloptguis/@srosisotoolgui/@tunedparameterpnl/copyValueToInitial.m

    function copyValueToInitial(this) 
% COPYVALUETOINITIAL  method to copy Value to Initial for currently
% selected table rows
%
 
% Author(s): A. Stothert 08-Oct-2005
% Copyright 2005-2006 The MathWorks, Inc.

%Handle to java object
h = this.getJavaHandle;

%Compute useful compensator row indices
CompIdx    = double(h.getCompensatorIndices)+1;

%For each selected row copy value to initial
rows = double(h.getTable.getSelectedRows)+1;

update = false;
for ct=1:numel(rows)
   if all(rows(ct)~=CompIdx)
      %Not a compensator row
      Comp  = find(rows(ct)>=CompIdx,1,'last');
      Param = rows(ct)-max(CompIdx(1:Comp));
      %Parameter  = this.findParameter(rows(ct)-sum(CompIdxIdx));
      Parameter  = this.findParameter(Comp,Param);
      pVal       = this.Data.Model.getValue(Parameter.pSpec);
      if ~isequal(pVal.Value,Parameter.pSpec.Initial)
         %Value and initial are different
         Parameter.pSpec.Initial = pVal.Value;
         update        = true;
      end
   end
end
if update 
   %Update the display
   this.updateTable; 
end