function [riseTime] = timeDomainSignal2RiseTime(Xin,Yin,percentReferenceLevel)
% Function that computes the rise time for input signal represented by [Xin,Yin],
% OUTPUT
% riseTime= vector of rise time values for the given input signal
%
% INPUTS:
% Xin = vector of time points for the input signal 
% Yin = vector of signal values corresponding to the time vector Xin
% percentReferenceLevel = two-element positive row vector specifying the reference 
% levels as a percentage of the waveform amplitude. The precent 
% reference levels must be in increasing order.

% Copyright 2020, The MathWorks, Inc.
if(length(Xin) ~= length(Yin))
    error(message('msblks:msblksMessages:SignalDataMismatch','[Xin Yin]'));
    %error('Length of time vector should be equal to the length of signal value vector');
elseif(length(percentReferenceLevel)~=2 || percentReferenceLevel(2) < percentReferenceLevel(1))
    error(message('msblks:msblksMessages:PercentRefLevel'));
    %error('The percent reference level is a two element vector and the values must be in increasing order.');
else
    % Using the 'risetime' command from signal processing toolbox.
    riseTime=risetime(Yin,Xin,'PercentReferenceLevels',percentReferenceLevel);
end
