Skip to content
Snippets Groups Projects
updateTsgStructWithCalCoeff.m 1.79 KiB
Newer Older
function updateTsgStructWithCalCoeff(hMainFig)
%
% This function is called after change option/parameter calibrations coeff
% type or when initialize tsgStruct
%
% Input
% -----
% hMainFig ............ Handle to the main user interface
%
% $Id$


% Get the data from the application GUI
% -------------------------------------
tsg = getappdata( hMainFig, 'tsg_data');

% define coefficients variables
% -----------------------------
var = {'SSJT_CALCOEF', 'CNDC_CALCOEF', 'SSTP_CALCOEF'};

% define coefficients names, celle array with first element with size
% COEF_CONV_SIZE
% -------------------------------------------------------------------
coeff_type = ...
  {{padding('DATE',tsg.dim.COEF_CONV_SIZE);'A';'B';'C';'D';'F0';''},...
   {padding('DATE',tsg.dim.COEF_CONV_SIZE);'A';'B';'C';'D';'M';'CPCOR'},...
   {padding('DATE',tsg.dim.COEF_CONV_SIZE);'A';'B';'C';'D';'F0';''}; ...
   {padding('DATE',tsg.dim.COEF_CONV_SIZE);'G';'H';'I';'J';'F0';''},...
   {padding('DATE',tsg.dim.COEF_CONV_SIZE);'G';'H';'I';'J';'CTCOR';'CPCOR'},...
   {padding('DATE',tsg.dim.COEF_CONV_SIZE);'G';'H';'I';'J';'F0';''}
  };
% get preference choice for calibrations type popup
% -------------------------------------------------
pref = tsg.preference.coeff_type_value;

% dynamically fill variables
% --------------------------
for i = 1:numel(var)
  if isempty(tsg.(var{i})) 
    for j = 1:tsg.dim.CALCOEF
      tsg.(var{i})(j) = NaN;
    end
  elseif isnan(tsg.(var{i})) 
    tsg.([var{i} '_CONV']) = [];
    for j = 1:tsg.dim.CALCOEF
      tsg.(var{i})(j) = NaN;
    end
  end
  % convert cell array of string to char array
  % ------------------------------------------
  tsg.([var{i} '_CONV']) = char(coeff_type{pref,i});
end

% Save tsg structure
% ------------------
setappdata( hMainFig, 'tsg_data', tsg);

end