## Copyright (C) 2009-2015 Lukas F. Reichlin
##
## This file is part of LTI Syncope.
##
## LTI Syncope is free software: you can redistribute it and/or modify
## it under the terms of the GNU General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## LTI Syncope is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with LTI Syncope. If not, see .
## -*- texinfo -*-
## @deftypefn{Function File} {} lsim (@var{sys}, @var{u})
## @deftypefnx{Function File} {} lsim (@var{sys1}, @var{sys2}, @dots{}, @var{sysN}, @var{u})
## @deftypefnx{Function File} {} lsim (@var{sys1}, @var{'style1'}, @dots{}, @var{sysN}, @var{'styleN'}, @var{u})
## @deftypefnx{Function File} {} lsim (@var{sys1}, @dots{}, @var{u}, @var{t})
## @deftypefnx{Function File} {} lsim (@var{sys1}, @dots{}, @var{u}, @var{t}, @var{x0})
## @deftypefnx{Function File} {[@var{y}, @var{t_ret}, @var{x}] =} lsim (@var{sys}, @var{u})
## @deftypefnx{Function File} {[@var{y}, @var{t_ret}, @var{x}] =} lsim (@var{sys}, @var{u}, @var{t})
## @deftypefnx{Function File} {[@var{y}, @var{t_ret}, @var{x}] =} lsim (@var{sys}, @var{u}, @var{t}, @var{x0})
## Simulate @acronym{LTI} model response to arbitrary inputs. If no output arguments are given,
## the system response is plotted on the screen.
##
##
## @strong{Inputs}
## @table @var
## @item sys
## @acronym{LTI} model. System must be proper, i.e. it shall not become a differentiator for
## ultra-high frequencies (pedantic.. but zeros are features of a transfer, not of a system).
## @item u
## Input signal(s). If @var{sys} is multi-input, then @var{u} needs a column per input.
## The columns must be consistent with, or define, (sampled) time, see below.
## If @var{sys} is single-input, a row vector, instead of column, is accepted as well.
## ( This friendly feature may have to be taken away, even if it reduces compatibility
## with Matlab : it gives possible inconsistencies
## with the help text to follow, and with an error message in __linear_simulation__ .)
## @item t
## Time vector or scalar.
##
## If @var{sys} is a continuous-time system, then it will be ZOH-discretized with
## sampling time @code{tsam} :
##
## * if @var{t} is a vector, then its entries shall be evenly spaced, and
## @code{tsam} equals the spacing. The first entry, being the starting time,
## does not have to equal zero.
##
## * if @var{t} is a scalar, then it is taken as the final time value @code{tfinal},
## whereas starting time is assumed zero. Sampling is computed as
## @code{tsam = tfinal/(rows(u)-1)} .
##
## If @var{sys} is a discrete-time system, then the width of the simulation time
## horizon is defined by @var{u}. A scalar @var{t} may be given, in which case it
## will serve as an offset @code{toff}, and a time vector will be constructed as :
## @code{[toff : tsam : toff+tsam*(rows(u)-1)]' }. If @var{t} is omitted, @code{toff} will be zero.
## @item x0
## Vector of initial conditions for each state. If not specified, a zero vector is assumed.
## @item 'style'
## Line style and color, e.g. 'r' for a solid red line or '-.k' for a dash-dotted
## black line. See @command{help plot} for details.
## @end table
##
## @strong{Outputs}
## @table @var
## @item y
## Output response array. Has as many rows as time samples (length of @var{t_ret})
## and as many columns as outputs.
## @item t_ret
## Column vector of reconstructed time. It is always evenly spaced.
## @item x
## State trajectories array. Has @code{length (t_ret)} rows and as many columns as states.
## @end table
##
## @seealso{impulse, initial, step}
## @end deftypefn
## Author: Lukas Reichlin
## Created: October 2009
## Version: 0.4