1 function obj=xltv(varargin)
\r
2 % Holds an 3d array 2d matrices which forms linear expressions.
\r
4 % Syntax: (* = optional)
\r
6 % obj = xltv(expression, Ts*, evalvar*, varsize*, interpolate*);
\r
11 % Data array containing expressions.
\r
13 % Sample point vector
\r
15 % 'Ts' is set to [0:size(array,3)-1]
\r
17 % Some data objects, such as xltv that use matrix multiplication, don't support
\r
18 % xvars, uvars and wvars. These objects need to know what variable(s) to use in the
\r
19 % evaluation. 'evalvar' contains this information. The variables x, t, w and u
\r
20 % are represented by the numbers 1, 2, 3 and 4 respectively.
\r
21 % evalvar=1 means that x will be used in the evaluation.
\r
22 % evalvar=[1 3] means that [x; u] will be used (x and u are, like always,
\r
23 % row vectors or scalars).
\r
24 % Example - the eval command of xltv ('expression' is a matrix):
\r
25 % evalvar=1 returns expression*x
\r
26 % evalvar=[1 4 3] returns expression*[x; w; u]
\r
27 % Note that xltv doesn't support empty evalvar vectors. For that
\r
28 % kind of functionallity, see xtable.
\r
30 % 'evalvar' will be set to 1, ie x will be multiplied to the right when evaluating.
\r
32 % Only needed when evaluating multiple variables, ie when 'evalvar' is a vector.
\r
33 % When differentiating an expression based on multiple variables, we need to know
\r
34 % the size of each variable (column vector) in order to extract the right columns of the
\r
35 % matrix. 'varsize' must be a vector of 4 elements representing the size of
\r
36 % [x t u w]. Not that if a particular variable isn't evaluated (ie its index is
\r
37 % not present in the evalvar vector), its size does not matter and can be set to 0.
\r
38 % Example: x=[1 2 3]', w=[1 2]', u=3 and evalvar=[1 4 3], the 'varsize' argument
\r
39 % must be set to [3 x 2 1], where x can be anything (preferably 1, since t is always
\r
41 % The gradient with respect to w will be a 6x6 matrix where column 4 and 5 will be
\r
42 % extracted from the expression matrix, and the remaining columns will contain zeros.
\r
44 % All columns in the expression matrix will be treated equally when differentiating.
\r
46 % Sets linear interpolation on=true or off=false.
\r
48 % 'interpolate' is set to false, ie interpolation is turned off.
\r
53 % The resulting data object.
\r
55 % Toolbox for nonlinear filtering.
\r
56 % Copyright (C) 2005 Jakob Rosén <jakob.rosen@gmail.com>
\r
58 % This program is free software; you can redistribute it and/or
\r
59 % modify it under the terms of the GNU General Public License
\r
60 % as published by the Free Software Foundation; either version 2
\r
61 % of the License, or (at your option) any later version.
\r
63 % This program is distributed in the hope that it will be useful,
\r
64 % but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
65 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
66 % GNU General Public License for more details.
\r
68 % You should have received a copy of the GNU General Public License
\r
69 % along with this program; if not, write to the Free Software
\r
70 % Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
\r
75 elseif isa(varargin{1},'xltv')
\r
83 % Declare the arguments
\r
89 % Fetch arguments, if they exist
\r
90 if nargin>=2; Ts=varargin{2}; end;
\r
91 if nargin>=3; evalvar=varargin{3}; end;
\r
92 if nargin>=4; varsize=varargin{4}; end;
\r
93 if nargin>=5; interpolate=varargin{5}; end;
\r
97 Ts=[0:size(array,3)-1]; % Ts default
\r
101 if isempty(evalvar)
\r
102 evalvar=1; % evalvar default = use x as multiplicator
\r
105 if isempty(varsize)
\r
106 varsize=[0 0 0 0]; % x t u w
\r
109 if isempty(interpolate)
\r
110 interpolate=false; % interpolate default
\r
113 exprsize=[size(array,1), size(array,2)];
\r
116 if size(Ts)~=size(array,3)
\r
117 error('''Ts'' and ''array'' do not match');
\r
122 if size(varsize,1)~=1||size(varsize,2)~=4
\r
123 error('''varsize'' must be a row vector of size 4.');
\r
128 obj.str='No string representation';
\r
129 obj.exprsize=exprsize;
\r
136 obj.islinear=true;
\r
137 obj.evalvar=evalvar;
\r
138 obj.varsize=varsize;
\r
140 obj.interpolate=interpolate;
\r
141 obj.description='Linear time-variant (LTV) expression';
\r
142 obj.gradx_idxstart=[]; % PRIVATE
\r
143 obj.gradx_idxlength=[]; % PRIVATE!
\r
144 obj.gradw_idxstart=[]; % PRIVATE
\r
145 obj.gradw_idxlength=[]; % PRIVATE!
\r
146 obj=class(obj,'xltv');
\r