function varargout = healthIndicatorDesigner(varargin)
%HEALTHINDICATORDESIGNER Health Indicator Designer App.
%
% healthIndicatorDesigner opens a new instance of the Health Indicator Designer
% app. The app lets you combine and select features for designing machinery
% health indicators. To import a feature dataset into the app, select a valid
% matrix or table variable from the 'Feature table' drop-down component.
%
% healthIndicatorDesigner(X) opens a new instance of the Health Indicator
% Designer app with the feature matrix or table specified as the input variable
% X. The variable X must exist in the MATLAB workspace.
%
% EXAMPLE: Construct a scalar health indicator from a matrix of correlated
% features
%   N = 100;
%   Z1 = cumsum(rand(N,1));
%   Z2 = 2*rand(N,1);
%
%   % Group of correlated trending features
%   X1 =  0.4*Z1 + randn(N,1);
%   X2 = -1.0*Z1 + randn(N,1);
%   X3 =  1.0*Z1 + randn(N,1);
%
%   % Group of correlated random features
%   X4 =  1.0*Z2 + 0.4*randn(N,1);
%   X5 = -1.0*Z2 + 0.4*randn(N,1);
%   X6 =  2.0*Z2 + 0.4*randn(N,1);
%
%   % Open the Health Indicator Designer app with the feature dataset
%   X = [X1,X2,X3,X4,X5,X6];
%   healthIndicatorDesigner(X)
%
% EXAMPLE (continued): Construct a scalar health indicator from a table of
% correlated features collected from two different machines
%   T = array2table(X);
%
%   % Data from two different machines used as condition variables in the app
%   c = categorical({'Machine 1','Machine 2'});
%   I = randperm(N) > floor(N/2);
%   T.Machine(I)  = c(1);
%   T.Machine(~I) = c(2);
%
%   % Open the Health Indicator Designer app with the feature dataset
%   healthIndicatorDesigner(T)
%
% See also DIAGNOSTICFEATUREDESIGNER

% Copyright 2023 The MathWorks, Inc.

narginchk(0,1);

% Check for required toolboxes and licenses.
[ready, msgID] = predmaintguis.internal.utils.checkRequiredToolboxes;
if ~ready
  error(message(msgID, mfilename));
end

% Create and launch the app.
if nargin > 0
  % Input variable provided
  name = inputname(1);
  value = varargin{1};
  if ~isempty(name) && ...
      predmaintguis.internal.apps.HealthIndicatorDesigner.isValidFeatureData(value)
    hApp = predmaintguis.internal.apps.HealthIndicatorDesigner(name);
  else
    error(message('predmaint:general:errInvalidInput'));
  end
else
  hApp = predmaintguis.internal.apps.HealthIndicatorDesigner;
end

if nargout > 0
  varargout{1} = hApp;
end
end
