function ntstool(command)
%NTSTOOL Neural Time Series app
%
%  Syntax
%    
%    ntstool
%    ntstool('close')
%    
%  Description
%    
%    NTSTOOL launches the Neural Network Time Series app. Use this app to
%    solve time series problems using a two-layer feed-forward network.
%
%    NTSTOOL('close') closes the window.

% Copyright 2007-2022 The MathWorks, Inc.

if nargin > 0
    command = convertStringsToChars(command);
else
    % No args (expected call) - assume "-v2" flag.
    command = '-v2';
end

try
    nnet.internal.app.common.errorIfPlatformNotSupported;
catch exception
    % Re-throw the error here in order that the error message comes from
    % the nnstart command itself. This results in a friendlier error
    % message, particularly on MATLAB mobile.
    throw(exception)
end

try
    switch command
        case '-v1'
            error(message("nnapp:timeseries:VersionFlagDeprecationError"));
        case '-v2'
            appOpener = nnet.internal.app.start.ToolstripAppOpener();
            appOpener.ntstool();
        case {'hide','close'}
            iCloseV2App();
        case nnet.internal.app.common.deprecatedAPICommands()
            error(message("nnapp:common:DeprecatedCommand", ...
                "ntstool", string(command)));
        otherwise
            error(message("nnapp:common:UnsupportedCommand", ...
                "ntstool", string(command)));
    end
catch me
    throwAsCaller(me);
end
end

function iCloseV2App()
app = getappdata(groot, "SHALLOWNETAPP_NEURALTIMESERIESTOOL");
delete(app);
end