function handle = plotSSystem( t,y,breakIndices,color,plotType,switchType )
%PLOTSSYSTEM plots the time simulation of a dynamical system
%
% Input arguments:
%   t:              the time points
%   y:              the (one-dimensional) output at the time points
%   breakIndices:   the indices at which the switching happens
%   color:          desired color for the plot
%   plotType:       'plot':     uses plot to plot the data
%                   'semilogy': uses semilogy to plot the data
%   switchType:     'static':   results from a time dependent switching
%                   'dynamic':  results from an output-dependent switching
%
% Output arguments:
%   handle:         a handle to the plot line (can be used for creating
%                   legend entries)
%
% Authors:
%   Philipp Schulze, pschulze@math.tu-berlin.de
%   Benjamin Unger, unger@math.tu-berlin.de
%
% Version:
%   1.0 (January 08, 2018)

    startInd = 1;
    for i=1:length(breakIndices)
        endInd = breakIndices(i);
        switch(plotType)
            case 'plot'
                handle = plot(t(startInd:endInd),y(startInd:endInd),'color',color);
            case 'semilogy'
                handle = semilogy(t(startInd:endInd),y(startInd:endInd),'color',color);
            otherwise
                error('Plot type %s not known.',plotType);
        end
        
        switch(switchType)
            case 'dynamic'
                startInd = endInd;
            case 'static'
                startInd = endInd+1;
        end
        if i==1
            hold on;
        end
    end
    hold off ;
end

