Ellipsoid tubes, tubes by instant of time and their projections
Definition. For any regularization matrix the quadratically regularized alternated reach set of system with uncertainty is
Note that if system doesn’t have uncertainty then .
By and denote tight external and internal approximations along good direction such as . Then the reach set by instant of time can be described as
where is the external ellipsoidal tube by instant of time.
Similar approxiamtion can be calculated with the internal ellipsoidal tube by instant of time :
Note that in general case ellipsoidal tube is not tight approximation. For more information see [GAG2012].
So, all in all, there are two types of ellipsoid tube objects that we can work with using Ellipsoidal Toolbox:
- ellipsoidal tubes that are described in gras.ellapx.smartdb.rels.EllTube class;
- tubes by instant of time described in gras.ellapx.smartdb.rels.EllUnionTube class
(see formula).
These two type of objects can be projected on specified subspaces. The projections of ellipsoid tubes can be either static or dynamic. The are described in gras.ellapx.smartdb.rels.EllTubeProj class. As for the tubes by instant of time, they can only be projected on static subspaces. These projections are described in gras.ellapx.smartdb.rels.EllUnionTubeStaticProj class. For more information about these types of projections and their differences and for examples see this link.
Ellipsoid tubes
There is a whole variety of operations upon ellipsoid tubes in Ellipsoidal Toolbox. We can, of course, create them. When the ellipsoid tube object is created, we can cut them, concatenate, interpolate, plot and project them and so on.
The instruments to create ellipsoid tube objects are several functions:
- fromQArrays method creates nEllTubes ellipsoid tube objects using an array of ellipsoid matrices and an array of ellipsoid centers specified at any point of time from timeVec;
- fromQMArrays method acts the same way as fromQArrays method, except for this one requires to specify an array of regularization marices specified at any point of time from timeVec;
- fromQMScaledArrays method acts the same way as fromQMArrays method, except for this one requires to also specify a vector of scale factors specified for every created ellipsoid tube;
- fromEllArray method creates ellipsoid tube object using an array of ellipsoids;
- fromEllMArray method creates ellipsoid tube object using an array of ellipsoids and an array of regularisation matrices.
Basically we can divide these methods into two groups, based od what objects they are using to create ellipsoid tube: an array of ellipsoid matrices with an array of ellipsoid centers (by using these methods we can create an ellipsoid tube object containing several ellipsoid tubes) or an array of ellipsoids (by using these methods we can create an ellipsoid tube object containing one ellipsoid tube). To illustrate the usage of these methods we have to describe several functions, that will be used in the process. Below are their descriptions.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 | % This function returns the values of arguments, that are the same for
% FROMQARRAYS, FROMQMARRAYS and FROMQMSCALEDARRAYS methods of creating an
% ellipsoid tube object. Basically, this function creates a set of
% arguments nessesary for creating an ellipsoid tube object containing
% nTubes ellipsoid tubes. Here nTubes is a random natural number in the
% range from one to ten.
%
function [nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = getData()
nTubes=randi(10,1);
nPoints=20;
nDims=3;
absTol=0.001;
relTol=0.001;
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
lsGoodDirVec=[1;0;0];
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
aMat=zeros(nDims,nPoints);
qArrayList=repmat({repmat(diag([0.1 0.2 0.3]),[1,1,nPoints])},1,nTubes);
end
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | % This function returns the values of arguments, that specify the type of
% approximation that will be used to create an ellipsoid tube object. It
% will be a random type of approximation (Internal or External). These
% arguments can be used while creating an ellipsoid tube object containing
% one ellipsoid tube or several ellipsoid tubes with the same type of
% approximation.
%
function [approxSchemaDescr, approxSchemaName, approxType] = getSameApprox()
type = randi(2,1);
if type == 1
approxSchemaDescr='Internal';
approxSchemaName='Internal';
approxType=gras.ellapx.enums.EApproxType.Internal;
else
approxSchemaDescr='External';
approxSchemaName='External';
approxType=gras.ellapx.enums.EApproxType.External;
end
end
|
Using the three above mentioned functions we can describe an examples of fromQArrays, fromQMArrays and fromQMScaledArrays methods’ usage.
| % An example of creating nTubes ellipsoid tube objects using fromQArrays
% function with the same type of approximation.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getData();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
fromMatEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 | % An example of creating nTubes ellipsoid tube objects using fromQArrays
% function with different types of approximation.
nPoints=10;
absTol=0.01;
relTol=0.01;
approxSchemaDescr={'Internal'; 'External'; 'External'};
approxSchemaName={'Internal'; 'External'; 'External'};
nDims=3;
nTubes=3;
lsGoodDirVec=[1;0;1];
aMat=zeros(nDims,nPoints);
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
approxType=[gras.ellapx.enums.EApproxType.Internal,...
gras.ellapx.enums.EApproxType.External,...
gras.ellapx.enums.EApproxType.External]';
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},...
1,nTubes);
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
fromMatEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
|
1
2
3
4
5
6
7
8
9
10
11
12
13 | % An example of creating nTubes ellipsoid tube objects using fromQMArrays
% function with the same type of approximation.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getData();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
mArrayList=repmat({repmat(diag([0.1 0.2 0.3]),[1,1,nPoints])},...
1,nTubes);
fromMatMEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQMArrays(...
qArrayList, aMat, mArrayList, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 | % An example of creating nTubes ellipsoid tube objects using fromQMArrays
% function with different types of approximation.
nPoints=10;
absTol=0.01;
relTol=0.01;
approxSchemaDescr={'Internal'; 'External'; 'External'};
approxSchemaName={'Internal'; 'External'; 'External'};
nDims=3;
nTubes=3;
lsGoodDirVec=[1;0;1];
aMat=zeros(nDims,nPoints);
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
approxType=[gras.ellapx.enums.EApproxType.Internal,...
gras.ellapx.enums.EApproxType.External,...
gras.ellapx.enums.EApproxType.External]';
mArrayList=repmat({repmat(diag([0.1 0.2 0.3]),[1,1,nPoints])},...
1,nTubes);
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},...
1,nTubes);
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
fromMatMEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQMArrays(...
qArrayList, aMat, mArrayList, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 | % An example of creating nTubes ellipsoid tube objects using fromQMScaledArrays
% function with the same type of approximation.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getData();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
mArrayList=repmat({repmat(diag([0.1 0.2 0.3]),[1,1,nPoints])},...
1,nTubes);
scaleFactor = ones(1,nTubes);
fromQMScaledArraysEllTubeObj = ...
gras.ellapx.smartdb.rels.EllTube.fromQMScaledArrays(...
qArrayList,aMat,mArrayList,timeVec,...
ltGoodDirArray,sTime,approxType,approxSchemaName,...
approxSchemaDescr,absTol, relTol,...
scaleFactor);
|
To use fromEllArray and fromEllMArray methods we nave to describe one more auxiliary function (as these methods create an ellipsoid tube object containing only one ellipsoid tube and we can not use getData function, because it returns data for crating random number of ellipsoid tubes).
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 | % This function returns the values of arguments, that are needed to use
% FROMELLARRAY and FROMELLMARRAY methods of creating an ellipsoid tube
% object. Basically, this function creates a set of arguments nessesary for
% creating an ellipsoid tube object containing one ellipsoid tube.
%
function [nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = getDataForOneTube()
nTubes=1;
nPoints=20;
nDims=3;
absTol=0.001;
relTol=0.001;
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
lsGoodDirVec=[1;0;0];
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
aMat=zeros(nDims,nPoints);
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},1,nTubes);
end
|
Now we can write examples of these methods’ usage.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of creating nTubes ellipsoid tube objects using FROMELLARRAY
% method.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getDataForOneTube();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
ellArray(nPoints) = ellipsoid();
for iElem = 1:nPoints
ellArray(iElem) = ellipsoid(aMat(:,iElem), qArrayList{1}(:,:,iElem));
end;
fromEllArrayEllTubeObj = gras.ellapx.smartdb.rels.EllTube.fromEllArray(...
ellArray,timeVec, ltGoodDirArray, sTime, approxType,...
approxSchemaName,approxSchemaDescr, absTol, relTol);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | % An example of creating nTubes ellipsoid tube objects using FROMELLMARRAY.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getDataForOneTube();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
ellArray(nPoints) = ellipsoid();
for iElem = 1:nPoints
ellArray(iElem) = ellipsoid(aMat(:,iElem), qArrayList{1}(:,:,iElem));
end;
mArrayList=repmat({repmat(diag([0.1 0.2 0.3]),[1,1,nPoints])},...
1,nTubes);
fromEllArrayEllTubeObj = gras.ellapx.smartdb.rels.EllTube.fromEllArray(...
ellArray,timeVec, ltGoodDirArray, sTime, approxType,...
approxSchemaName,approxSchemaDescr, absTol, relTol);
|
As we can see in all these examples, we can specify how many ellipsoid tubes we want to create, which type of arrpoximation to use. Also we can create ellipsoid tube objects, which will contain several ellipsoid tubes with different types of approximation.
After creation of ellipsoid tube objects we can do several operations with them. Below is the getEllTube function that create an ellipsoid tube object containing one or several ellipsoid tubes with specified type of approximation, on specified time vector with specified time points. This function will be used further down to illustrate other methods that we can use while working with ellipsoid tube objects.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | % An example of creating an ellipsoid tube object containing nTubes
% ellipsoid tubes from timeBegin to timeEnd time with specified type of
% approximation.
%
function ellTubeObj = getEllTube(nTubes,timeBeg,timeEnd,type,nPoints)
nDims=3;
absTol=0.001;
relTol=0.001;
timeVec=(timeBeg+1/nPoints):(1/nPoints):timeEnd;
sTime=timeVec(randi(nPoints,1));
lsGoodDirVec=[1;0;0];
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
aMat=zeros(nDims,nPoints);
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},1,nTubes);
if type == 1
approxSchemaDescr='Internal';
approxSchemaName='Internal';
approxType=gras.ellapx.enums.EApproxType.Internal;
else
approxSchemaDescr='External';
approxSchemaName='External';
approxType=gras.ellapx.enums.EApproxType.External;
end
ellTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
end
|
As we have created an ellipsoid tube object, we can get all the types of differet data about it. There is a set of methods that can give information about the data stored in the object and give access to it.
| % An example of GETDATA method's usage.
nTubes=5;
nPoints = 100;
timeBeg=0;
timeEnd=1;
type = 2;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
data = ellTubeObj.getData();
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of GETELLARRAY method's usage.
[nTubes, nPoints, nDims, absTol, relTol, timeVec,...
sTime, lsGoodDirVec, ltGoodDirArray, aMat, qArrayList] = ...
gras.ellapx.smartdb.test.examples.getDataForOneTube();
[approxSchemaDescr, approxSchemaName, approxType] = ...
gras.ellapx.smartdb.test.examples.getSameApprox();
ellArray(nPoints) = ellipsoid();
for iElem = 1:nPoints
ellArray(iElem) = ellipsoid(aMat(:,iElem), qArrayList{1}(:,:,iElem));
end;
fromEllArrayEllTubeObj = gras.ellapx.smartdb.rels.EllTube.fromEllArray(...
ellArray,timeVec, ltGoodDirArray, sTime, approxType,...
approxSchemaName,approxSchemaDescr, absTol, relTol);
data = fromEllArrayEllTubeObj.getEllArray(approxType);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98 | nTubes=5;
nPoints = 100;
timeBeg=0;
timeEnd=1;
type = 2;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
%
% get the list of field descriptions
%
descr = ellTubeObj.getFieldDescrList();
%
% get for given field a nested logical/cell array containing is-null
% indicators for cell content. For example, for approxSchemaName field.
%
isNull = ellTubeObj.getFieldIsNull('approxSchemaName');
%
% get for given field logical vector determining whether value of this
% field in each cell is null or not. For example, for approxSchemaName field.
%
valueIsNull = ellTubeObj.getFieldIsValueNull('approxSchemaName');
%
% get the list of field names
%
name = ellTubeObj.getFieldNameList();
%
% project object with specified fields. For example, with fields that are
% not to be cut or concatenated.
%
nameList = ellTubeObj.getNoCatOrCutFieldsList();
proj = ellTubeObj.getFieldProjection(nameList);
%
% get the list of field types
%
type = ellTubeObj.getFieldTypeList();
%
% get the list of field type specifications. Field type specification is a
% sequence of type names corresponding to field value types starting with
% the top level and going down into the nested content of a field (for a
% field having a complex type).
%
typeSpec = ellTubeObj.getFieldTypeSpecList();
% or
typeSpec = ellTubeObj.getFieldTypeSpecList(nameList);
%
% get a matrix composed from the size vectorsfor the specified fields
%
valueSizeMat = ellTubeObj.getFieldValueSizeMat(nameList);
%
% get a vector indicating whether a particular field is composed of null
% values completely
%
valueNull = ellTubeObj.getIsFieldValueNull(nameList);
%
% get a size vector for the specified dimensions. If no dimensions are
% specified, a size vector for all dimensions up to minimum dimension is
% returned
minDimensionSize = ellTubeObj.getMinDimensionSize();
%
% get a minimum dimensionality for a given object
%
minDimensionality = ellTubeObj.getMinDimensionality();
%
% get a number of elements in a given object
%
nElems = ellTubeObj.getNElems();
%
% get a number of fields in a given object
%
nFiedls = ellTubeObj.getNFields();
%
% get a number of tuples in a given object
%
nTuples = ellTubeObj.getNTuples();
%
% get sort index for all tuples of given relation with respect to some of
% its fields
%
sortIndex = ellTubeObj.getSortIndex(nameList);
% also we can specify the direction of sorting ('asc' or 'desc')
sortIndex = ellTubeObj.getSortIndex(nameList,'Direction','asc');
%
% get tuples with given indices from given relation
%
tuples = ellTubeObj.getTuples([1,2,3]);
%
% get tuples from given relation such that afixed index field contains
% values from a given set of value
%
filteredTuples = ellTubeObj.getTuplesFilteredBy('sTime', 1);
%
% get internal representation for a set of unique tuples for given relation
%
uniqueData = ellTubeObj.getUniqueData();
%
% get a relation containing the unique tuples from the original relation
%
uniqueTuples = ellTubeObj.getUniqueTuples();
|
Also we can copy the object, clear all the data, save it in a file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42 | nTubes=5;
nPoints = 100;
timeBeg=0;
timeEnd=1;
type = 2;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
%
% get a copy of the object
%
ellCopy = ellTubeObj.getCopy();
%
% delete all the data from the object
%
ellTubeObj.clearData();
ellTubeObj =...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
%
% create a copy of a specified object via calling a copy constructor for
% the object class
%
cloneObj = ellTubeObj.clone();
%
% remove all duplicate tuples from the relation
%
noDuplicate = cloneObj.removeDuplicateTuples();
%
% write a content of relation into Excel spreadsheet file
%
ellTubeObj.writeToCSV('path');
%
% write a content of relation into Excel spreadsheet file
%
fileName = ellTubeObj.writeToXLS('path');
%
% display a content of the given relation as a data grid UI component
%
ellTubeObj.dispOnUI();
%
% put some textual information about object in screen
%
ellTubeObj.display();
|
As we have created the object, we can work with it. Below is the example of concatenating ellipsoid tube objects. We can concatenate objects containing one or several ellipsoid tubes with the same type of approximation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 | % An example of concatenating ellipsoid tube objects containing random
% number of ellipsoid tubes (from one to ten tubes).
%
nTubes = randi(10,1);
nPoints = 20;
type = 1;
timeBeg1 = 0;
timeEnd1 = 1;
firstEllTubeObj =...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg1,timeEnd1,type,nPoints);
timeBeg2 = 1;
timeEnd2 = 2;
secondEllTubeObj =...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg2,timeEnd2,type,nPoints);
%
% Concatenating firstEllTube and secondEllTube on [timeBeg1, timeEnd2]
% vector of time.
%
resEllTubeObj = firstEllTubeObj.cat(secondEllTubeObj);
%
% Concatenating the same firstEllTube and secondEllTube on [timeBeg1,timeEnd2]
% vector of time, but the sTime and values of properties corresponding to
% sTime are taken from secondEllTube.
%
resEllTubeObj = firstEllTubeObj.cat(secondEllTubeObj,'isReplacedByNew',true);
%
% Concatenating the same firstEllTube and secondEllTube on [timeBeg1,timeEnd2]
% vector of time, but the sTime and values of properties corresponding to
% sTime are taken from firstEllTube.
%
resEllTubeObj = firstEllTubeObj.cat(secondEllTubeObj,'isReplacedByNew',false);
%
% Note that we cannot concatenate ellipsoid tubes with overlapping time
% limits.
%
|
As we can concatenate ellipsoid tubes, it is logical to be possible to cut ellipsoid tubes, leaving only part of it at specified vector of time or point of time. Below are the exmples:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of usage of CUT function from EllTubeBasic class. In
% this example an ellipsoid tube object is created, using TimeVec time
% vector. Then it is cut using cutTimeVec time vector.
%
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
timeVec = ellTubeObj.timeVec{1,:};
cutTimeVec = [timeVec(2) timeVec(7)];
cutVecEllTubeObj = ellTubeObj.cut(cutTimeVec);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of usage of CUT function from EllTubeBasic class. In
% this example an ellipsoid tube object is created, using TimeVec time
% vector. Then it is cut using cutTimePoint point
% of time.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
timeVec = ellTubeObj.timeVec{1,:};
cutTimePoint = timeVec(randi(size(timeVec,2),1));
cutPointEllTubeObj = ellTubeObj.cut(cutTimePoint);
|
After cutting, we can interpolate the resulting tube, using new time vector. Take notice that we have to make sure that the first and the last elements in old and new vectors of time are the same.
1
2
3
4
5
6
7
8
9
10
11
12
13 | % An example of usage of INTERP function. In this example an ellipsoid tube
% object is created, using oldTimeVec time vector. Then it is interpolated
% on newTimeVec time vector.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
newNPoints=50;
newTimeVec = (1/nPoints):(1/newNPoints):1;
interpEllTubeObj = ellTubeObj.interp(newTimeVec);
|
After that we can thin out the new ellipsoid tube, removing ellipsoids at sertain points of time.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 | % An example of usage of THINOUTTUPLES method. In this example an ellipsoid
% tube object is created, using TimeVec time vector. Then it is thinned out
% using indVec vector of random indices of elements from timeVec.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
newnPoints=50;
newTimeVec = (1/nPoints):(1/newnPoints):1;
interpEllTubeObj = ellTubeObj.interp(newTimeVec);
indVec = randi(nPoints,1,5);
thinOutEllTubeObj = ellTubeObj.thinOutTuples(indVec);
|
Then we can also calculate new scale factor for specified fields:
1
2
3
4
5
6
7
8
9
10
11
12
13 | % An example of using SCALE method to calculate and set new
% scaleFactor for fields in ellipsoid tube object.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
newnPoints=50;
newTimeVec = (1/nPoints):(1/newnPoints):1;
interpEllTubeObj = ellTubeObj.interp(newTimeVec);
ellTubeObj.scale(@(varargin)2,{});
|
Also we can compare objects using method isEqual.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 | % An example ISEQUAL function usage. In it two ellipsoid tube objects are
% created and compared. This is the example of the siplest usage of this
% function with the minimum of input arguments. These ellipsoid tubes are
% not equal because of different lsGoodDirVec vectors.
nPoints=10;
absTol=0.01;
relTol=0.01;
approxSchemaDescr='Internal';
approxSchemaName='Internal';
nDims=3;
nTubes=1;
lsGoodDirVec=[1;0;1];
aMat=zeros(nDims,nPoints);
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
approxType=gras.ellapx.enums.EApproxType.Internal;
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},...
1,nTubes);
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
firstEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
lsGoodDirVec=[1;0;0];
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
secondEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
firstEllTubeObj.isEqual(secondEllTubeObj);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 | % An example ISEQUAL function usage. In it two ellipsoid tube objects are
% created and compared. These ellipsoid tubes are equal.
nPoints=10;
absTol=0.01;
relTol=0.01;
approxSchemaDescr='Internal';
approxSchemaName='Internal';
nDims=3;
nTubes=1;
lsGoodDirVec=[1;0;1];
aMat=zeros(nDims,nPoints);
timeVec=(1/nPoints):(1/nPoints):1;
sTime=timeVec(randi(nPoints,1));
approxType=gras.ellapx.enums.EApproxType.Internal;
qArrayList=repmat({repmat(diag([1 2 3]),[1,1,nPoints])},...
1,nTubes);
ltGoodDirArray=repmat(lsGoodDirVec,[1,nTubes,nPoints]);
firstEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
secondEllTubeObj=gras.ellapx.smartdb.rels.EllTube.fromQArrays(...
qArrayList, aMat, timeVec,...
ltGoodDirArray, sTime, approxType, approxSchemaName,...
approxSchemaDescr, absTol, relTol);
firstEllTubeObj.isEqual(secondEllTubeObj,'checkFieldOrder',false,...
'checkTupleOrder',false,'maxTolerance',0.0001,...
'maxRelativeTolerance',0.0001);
|
At last there are several methods for projecting ellipsoid tubes on the specified spaces. The first method projects the ellipsoid tube on specified space creating the specified type of projection.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of calculating ellipsoid tube object projection using PROJECT
% method.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
projType = gras.ellapx.enums.EProjType.Static;
projMat = [1 0; 0 1; 0 0]';
p = @gras.ellapx.smartdb.test.examples.fGetProjMat;
[ellTubeProjObj,indProj2OrigVec] = ellTubeObj.project(projType,...
{projMat},p);
|
The second method projects the ellipsoid tube onto subspace defined by vectors of standart basis with indices specified in indVec.
| % Examples of calculating ellipsoid tube object projection to basic orths
% using PROJECTTOORTHS function. This is an example of projectToOrths usage
% with one input variable. The default value of projection type is used.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
ellTubeProjObj = ellTubeObj.projectToOrths([1,2]);
|
1
2
3
4
5
6
7
8
9
10
11
12 | % Examples of calculating an ellipsoid tube object projection to basic orths
% using PROJECTTOORTHS function. This is an example of projectToOrths usage
% with specified projection type.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
projType = gras.ellapx.enums.EProjType.DynamicAlongGoodCurve;
ellTubeProjObj = ellTubeObj.projectToOrths([1,2], projType);
|
Also there is a method for calculating only static projections.
| % Examples of calculating ellipsoid tube object static projection using
% PROJECTSTATIC function.
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
projMat = [1 0; 0 1; 0 0]';
ellTubeProjObj = ellTubeObj.projectStatic(projMat);
|
For creating the projection matrix a special function is used in all of these examples.
| function [projOrthMatArray,projOrthMatTransArray]=...
fGetProjMat(projMat,timeVec,varargin)
nPoints=length(timeVec);
projOrthMatArray=repmat(projMat,[1,1,nPoints]);
projOrthMatTransArray=repmat(projMat.',[1,1,nPoints]);
end
|
Tubes by instant of time
As with ellipsoid tube objects, there are several methods that we can use while working with tubes by instant of time. First of all we can create tubes by instant of time using fromEllTubes method:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | % An example of creating EllUnionTube object using FROMELLTUBES method.
aMat = [0 1; 0 0];
bMat = eye(2);
SUBounds = struct();
SUBounds.center = {'sin(t)'; 'cos(t)'};
SUBounds.shape = [9 0; 0 2];
sys = elltool.linsys.LinSysContinuous(aMat, bMat, SUBounds);
x0EllObj = ell_unitball(2);
timeVec = [0 10];
dirsMat = [1 0; 0 1]';
rsObj = elltool.reach.ReachContinuous(sys, x0EllObj, dirsMat, timeVec);
ellTubeObj = rsObj.getEllTubeRel();
unionEllTubeObj = ...
gras.ellapx.smartdb.rels.EllUnionTube.fromEllTubes(ellTubeObj);
|
From here on we will use the getUnion function so we can get a tube by instant of time and work with it further on. As we have created a tubes by instant of time object, we can get all the types of differet data about it. There is a set of methods that can give information about the data stored in the object and give access to it.
| % An example of GETDATA method's usage.
ellUnionObj = gras.ellapx.smartdb.test.examples.getUnion();
data = ellUnionObj.getData();
|
| % An example of GETELLARRAY method's usage.
ellUnionObj = gras.ellapx.smartdb.test.examples.getUnion();
approxType = ellUnionObj.approxType;
data = ellUnionObj.getEllArray(approxType);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 | ellUnionObj = gras.ellapx.smartdb.test.examples.getUnion();
%
% get the list of field descriptions
%
descr = ellUnionObj.getFieldDescrList();
%
% get for given field a nested logical/cell array containing is-null
% indicators for cell content. For example, for approxSchemaName field.
%
isNull = ellUnionObj.getFieldIsNull('approxSchemaName');
%
% get for given field logical vector determining whether value of this
% field in each cell is null or not. For example, for approxSchemaName field.
%
valueIsNull = ellUnionObj.getFieldIsValueNull('approxSchemaName');
%
% get the list of field names
%
name = ellUnionObj.getFieldNameList();
%
% project object with specified fields. For example, with fields that are
% not to be cut or concatenated.
%
nameList = ellUnionObj.getNoCatOrCutFieldsList();
proj = ellUnionObj.getFieldProjection(nameList);
%
% get the list of field types
%
type = ellUnionObj.getFieldTypeList();
%
% get the list of field type specifications. Field type specification is a
% sequence of type names corresponding to field value types starting with
% the top level and going down into the nested content of a field (for a
% field having a complex type).
%
typeSpec = ellUnionObj.getFieldTypeSpecList();
% or
typeSpec = ellUnionObj.getFieldTypeSpecList(nameList);
%
% get a matrix composed from the size vectorsfor the specified fields
%
valueSizeMat = ellUnionObj.getFieldValueSizeMat(nameList);
%
% get a vector indicating whether a particular field is composed of null
% values completely
%
valueNull = ellUnionObj.getIsFieldValueNull(nameList);
%
% get a size vector for the specified dimensions. If no dimensions are
% specified, a size vector for all dimensions up to minimum dimension is
% returned
minDimensionSize = ellUnionObj.getMinDimensionSize();
%
% get a minimum dimensionality for a given object
%
minDimensionality = ellUnionObj.getMinDimensionality();
%
% get a number of elements in a given object
%
nElems = ellUnionObj.getNElems();
%
% get a number of fields in a given object
%
nFiedls = ellUnionObj.getNFields();
%
% get a number of tuples in a given object
%
nTuples = ellUnionObj.getNTuples();
%
% get sort index for all tuples of given relation with respect to some of
% its fields
%
sortIndex = ellUnionObj.getSortIndex(nameList);
% also we can specify the direction of sorting ('asc' or 'desc')
sortIndex = ellUnionObj.getSortIndex(nameList,'Direction','asc');
%
% get tuples with given indices from given relation
%
tuples = ellUnionObj.getTuples([1,2,3]);
%
% get tuples from given relation such that afixed index field contains
% values from a given set of value
%
filteredTuples = ellUnionObj.getTuplesFilteredBy('sTime', 1);
%
% get internal representation for a set of unique tuples for given relation
%
uniqueData = ellUnionObj.getUniqueData();
%
% get a relation containing the unique tuples from the original relation
%
uniqueTuples = ellUnionObj.getUniqueTuples();
|
Also we can copy the object, clear all the data, save it in a file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 | ellUnionObj = gras.ellapx.smartdb.test.examples.getUnion();
%
% get a copy of the object
%
ellCopy = ellUnionObj.getCopy();
%
% delete all the data from the object
%
ellUnionObj.clearData();
ellUnionObj = gras.ellapx.smartdb.test.examples.getUnion();
%
% create a copy of a specified object via calling a copy constructor for
% the object class
%
cloneObj = ellUnionObj.clone();
%
% remove all duplicate tuples from the relation
%
noDuplicate = cloneObj.removeDuplicateTuples();
%
% write a content of relation into Excel spreadsheet file
%
ellUnionObj.writeToCSV('path');
%
% write a content of relation into Excel spreadsheet file
%
fileName = ellUnionObj.writeToXLS('path');
%
% display a content of the given relation as a data grid UI component
%
ellUnionObj.dispOnUI();
%
% put some textual information about object in screen
%
ellUnionObj.display();
|
Also we can compare tubes by instant of time using isEqual method.
| % An example of ISEQUAL method usage. The compared ellTubeUnions are not
% equal because one has external approximation, and the other has internal
% approximation.
firstUnionObj = gras.ellapx.smartdb.test.examples.getUnionExt();
secondUnionObj = gras.ellapx.smartdb.test.examples.getUnionInt();
res = firstUnionObj.isEqual(secondUnionObj);
|
At last, as it has already been said tubes by instant of time can be projected only on static subspaces. It can be done in two ways.
| % An example of calculating EllTubeUnion object's projection using PROJECT
% method. For EllTubeUnion objects the type of projection can only be Static.
unionEllTubeObj = ...
gras.ellapx.smartdb.test.examples.getUnion();
projType = gras.ellapx.enums.EProjType.Static;
projMat = [1 0; 0 1]';
p = @gras.ellapx.smartdb.test.examples.fGetProjMat;
[ellTubeProjObj,indProj2OrigVec] = unionEllTubeObj.project(projType,...
{projMat},p);
|
| % Example of PROJECTSTATIC function usage for creating a projection of
% EllTubeUnion object.
unionEllTubeObj = ...
gras.ellapx.smartdb.test.examples.getUnion();
projMatList = {[1 0;0 1]};
statEllTubeProjObj = unionEllTubeObj.projectStatic(projMatList);
|
As for ellipsoid tube projections, a special function is used to create the projection matrix for tubes by instant of time:
| function [projOrthMatArray,projOrthMatTransArray]=...
fGetProjMat(projMat,timeVec,varargin)
nPoints=length(timeVec);
projOrthMatArray=repmat(projMat,[1,1,nPoints]);
projOrthMatTransArray=repmat(projMat.',[1,1,nPoints]);
end
|
Projections of ellipsoid tubes and tubes by instant of time
As it has already been said we can create either static or dynamic projections for ellipsoid tubes and only static projections for tubes by instant of time. There are several methods in Ellipsoidal Toolbox for that. Most of them has already been described:
- project, projectStatic and projectToOrths for ellipsoid tubes;
- project and projectStatic for tubes by instant of time.
It should be mentioned that from here on all the examples are written for ellipsoid tube projections, but their usage is the same for the projections of tubes by instant of time. We wiil use getProj function to create ellipsoid tube projection that we will work with.
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | function ellTubeProjObj = getProj()
nTubes=1;
nPoints = 20;
timeBeg=0;
timeEnd=1;
type = 1;
ellTubeObj=...
gras.ellapx.smartdb.test.examples.getEllTube(nTubes,timeBeg,timeEnd,type,nPoints);
projType = gras.ellapx.enums.EProjType.Static;
projMat = [1 0; 0 1; 0 0]';
p = @gras.ellapx.smartdb.test.examples.fGetProjMat;
[ellTubeProjObj,indProj2OrigVec] = ellTubeObj.project(projType,...
{projMat},p);
end
|
As with ellipsoid tubes and tubes by instant of time we can get all the types of differet data about projections. There is a set of methods that can give information about the data stored in the object and give access to it.
| % An example of GETDATA method's usage.
ellTubeProjObj = gras.ellapx.smartdb.test.examples.getProj();
data = ellTubeProjObj.getData();
|
| % An example of GETELLARRAY method's usage.
ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
approxType = ellProjObj.approxType;
data = ellProjObj.getEllArray(approxType);
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92 | ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
%
% get the list of field descriptions
%
descr = ellProjObj.getFieldDescrList();
%
% get for given field a nested logical/cell array containing is-null
% indicators for cell content. For example, for approxSchemaName field.
%
isNull = ellProjObj.getFieldIsNull('approxSchemaName');
%
% get for given field logical vector determining whether value of this
% field in each cell is null or not. For example, for approxSchemaName field.
%
valueIsNull = ellProjObj.getFieldIsValueNull('approxSchemaName');
%
% get the list of field names
%
name = ellProjObj.getFieldNameList();
%
% project object with specified fields. For example, with fields that are
% not to be cut or concatenated.
%
nameList = ellProjObj.getNoCatOrCutFieldsList();
proj = ellProjObj.getFieldProjection(nameList);
%
% get the list of field types
%
type = ellProjObj.getFieldTypeList();
%
% get the list of field type specifications. Field type specification is a
% sequence of type names corresponding to field value types starting with
% the top level and going down into the nested content of a field (for a
% field having a complex type).
%
typeSpec = ellProjObj.getFieldTypeSpecList();
% or
typeSpec = ellProjObj.getFieldTypeSpecList(nameList);
%
% get a matrix composed from the size vectorsfor the specified fields
%
valueSizeMat = ellProjObj.getFieldValueSizeMat(nameList);
%
% get a vector indicating whether a particular field is composed of null
% values completely
%
valueNull = ellProjObj.getIsFieldValueNull(nameList);
%
% get a size vector for the specified dimensions. If no dimensions are
% specified, a size vector for all dimensions up to minimum dimension is
% returned
minDimensionSize = ellProjObj.getMinDimensionSize();
%
% get a minimum dimensionality for a given object
%
minDimensionality = ellProjObj.getMinDimensionality();
%
% get a number of elements in a given object
%
nElems = ellProjObj.getNElems();
%
% get a number of fields in a given object
%
nFiedls = ellProjObj.getNFields();
%
% get a number of tuples in a given object
%
nTuples = ellProjObj.getNTuples();
%
% get sort index for all tuples of given relation with respect to some of
% its fields
%
sortIndex = ellProjObj.getSortIndex(nameList);
% also we can specify the direction of sorting ('asc' or 'desc')
sortIndex = ellProjObj.getSortIndex(nameList,'Direction','asc');
%
% get tuples with given indices from given relation
%
tuples = ellProjObj.getTuples(1);
%
% get tuples from given relation such that afixed index field contains
% values from a given set of value
%
filteredTuples = ellProjObj.getTuplesFilteredBy('sTime', 1);
%
% get internal representation for a set of unique tuples for given relation
%
uniqueData = ellProjObj.getUniqueData();
%
% get a relation containing the unique tuples from the original relation
%
uniqueTuples = ellProjObj.getUniqueTuples();
|
Also we can copy the object, clear all the data, save it in a file.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35 | ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
%
% get a copy of the object
%
ellCopy = ellProjObj.getCopy();
%
% delete all the data from the object
%
ellProjObj.clearData();
ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
%
% create a copy of a specified object via calling a copy constructor for
% the object class
%
cloneObj = ellProjObj.clone();
%
% remove all duplicate tuples from the relation
%
noDuplicate = cloneObj.removeDuplicateTuples();
%
% write a content of relation into Excel spreadsheet file
%
ellProjObj.writeToCSV('path');
%
% write a content of relation into Excel spreadsheet file
%
fileName = ellProjObj.writeToXLS('path');
%
% display a content of the given relation as a data grid UI component
%
ellProjObj.dispOnUI();
%
% put some textual information about object in screen
%
ellProjObj.display();
|
Also we can compare ellipsoid tube projections using isEqual method.
| % An example of ISEQUAL method usage. The compared ellTubeProjections are
% equal.
firstProjObj = gras.ellapx.smartdb.test.examples.getProj();
secondProjObj = gras.ellapx.smartdb.test.examples.getProj();
res = firstProjObj.isEqual(secondProjObj);
|
And finally we can plot out results using one of three methods: plot, plotExt (for external approximation) or plotInt (for internal approximation).
| % An example of calculating ellipsoid tube object projection using PROJECT
% function.
ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
plObj=smartdb.disp.RelationDataPlotter();
ellProjObj.plot(plObj);
|
| % An example of plotting the projection of the ellipsoid tube internal approximation
% object using PLOTINT method.
ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
ellProjObj.plotInt();
|
| % An example of plotting the projection of the ellipsoid tube external approximation
% object using PLOTEXT method.
ellProjObj = gras.ellapx.smartdb.test.examples.getProj();
ellProjObj.plotExt();
|
All the three methods have several properties connected to the properties of the image, for example: transparency, color, line width and so on.
To read more about the differences of these projections goto. Also there you can find some illustrations for both ellTube projections and ellUnionTube projections.
[GAG2012] | Gagarinov P.V. 2012. Computation of Alternated Reachability Tubes for Linear Control Systems under Uncertainty. Moscow University Computational Mathematics and Cybernetics, 2012, Vol. 36, No. 4, pp. 169–177. |