function waveletTimeFrequencyAnalyzer(signal)
% WAVELETTIMEFREQUENCYANALYZER Visualize scalogram of signals
%
%   WAVELETTIMEFREQUENCYANALYZER opens the Wavelet Time-Frequency Analyzer
%   app. After the app initializes, import a signal for analysis by clicking
%   the Import button.
%
%   WAVELETTIMEFREQUENCYANALYZER(SIG) opens the Wavelet Time-Frequency
%   Analyzer app, imports, and plots the scalogram of the signal, SIG. SIG
%   is a double- or single-precision vector with real- or complex-valued
%   elements, or a timetable with a single double- or single-precision
%   variable with real- or complex-valued elements.
%
%   % Example:
%   %   Load the Kobe earthquake data. Display its scalogram by importing 
%   %   the signal from the workspace to the Wavelet Time-Frequency Analyzer. 
%  
%   load kobe
%   waveletTimeFrequencyAnalyzer(kobe)
%

%   Copyright 2021 The MathWorks, Inc.

    if nargin
        validateInput(signal);
        wavelettfanalyzer.internal.TimeFrequencyAnalyzerImpl.setGetInstance(signal, inputname(1));
    else
        wavelettfanalyzer.internal.TimeFrequencyAnalyzerImpl.setGetInstance();
    end
end

function validateInput(input)
    if istimetable(input)
        [import, errorMessage] = wavelettfanalyzer.internal.Utilities.checkTimetable(input);
        if ~import
            error(errorMessage);
        end
    elseif isa(input,"gpuArray") || isa(input,"dlarray")
        error(message('wavelet_tfanalyzer:wavelettfanalyzer:GPUorDLarray'));
    else
        validateattributes(input,{'double','single'}, {'vector','finite'});
        if numel(input) < 4
            error(string(getString(message("wavelet_tfanalyzer:wavelettfanalyzer:tooShortErrorMessage"))));
        end
    end
end
