Skip to content

Commit

Permalink
Issue #56:
Browse files Browse the repository at this point in the history
Divided the initial snippet and added more snippets
  • Loading branch information
marinapotashenkova authored and irublev committed Mar 1, 2018
1 parent c03fd4a commit 3c11289
Show file tree
Hide file tree
Showing 10 changed files with 62 additions and 35 deletions.
37 changes: 2 additions & 35 deletions products/+elltool/+doc/+snip/s_chapter06_section07_snippet01.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
phi0Vec = [0; 0];
lVec = [5; 5];
sVec = [3; 3];
alphaVec = [3; 10];

kVec = [0; 0];
g = 9.8;

Expand Down Expand Up @@ -44,37 +44,4 @@
aMat = [0 0 1 0; 0 0 0 1; y11 y12 y1 y2; x11 x12 x1 x2];
bMat = [0 0; 0 0; y3 y4; x3 x4];

x0Vec = [0; 0; 0; 0];
endTime=5;
% after initializing we create ellipsoid for control function
diagMat = diag(alphaVec);
uEllObj = ellipsoid(diagMat);
% define linear systems
linSys=elltool.linsys.LinSysContinuous(aMat, bMat, uEllObj);
% initialize direction matrix
nShape = 4;
mSize = 10;
dirMat = 2*(rand(nShape, mSize) - 0.5);
for iElem = 1 : mSize
dirMat(:, iElem) = dirMat(:, iElem) ./ norm(dirMat(:, iElem));
end;
% set of start coordinates
x0EllObj = 1E-2 * ell_unitball(4) + x0Vec;
% calculate solvability set
timeVec = [endTime, 0];
rsTube = elltool.reach.ReachContinuous(linSys, x0EllObj, dirMat, ...
timeVec, 'isRegEnabled', true, 'isJustCheck', false, 'regTol', 1e-3);
% create projection matrix and draw projection on current axis (z_3, z_4)
v1v2Mat = [0 0 1 0 ; 0 0 0 1]';
prTube = rsTube.projection(v1v2Mat);
prTube.plotByIa();
hold on;
ylabel('z_3'); zlabel('z_4');
rotate3d on;
% create projection matrix and draw projection on current axis (z_3, z_4)
v1v2Mat = [1 0 0 0 ; 0 1 0 0]';
prTube = rsTube.projection(v1v2Mat);
prTube.plotByIa();
hold on;
ylabel('z_1'); zlabel('z_2');
rotate3d on;
endTime = 5;
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alphaVec = [3; 10];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
alphaVec = [10; 10];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x0Vec = [0; 0; 0; 0];
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
x0Vec = [pi / 8; pi / 8; 0; 0];
24 changes: 24 additions & 0 deletions products/+elltool/+doc/+snip/s_chapter06_section07_snippet06.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
% after initializing we create ellipsoid for control function
diagMat = diag(alphaVec);
uEllObj = ellipsoid(diagMat);
% define linear systems
linSysObj=elltool.linsys.LinSysContinuous(aMat, bMat, uEllObj);
% initialize direction matrix
nDims = 4;
nDirs = 1;
dirMeshVec = 0 : (2 * pi / nDirs) : 2 * pi;
dirNum = length(dirMeshVec) ^ nDims;
[a1, a2, a3, a4] = ndgrid(dirMeshVec, dirMeshVec, dirMeshVec, dirMeshVec);
lineDir1Mat = reshape(a1, [1, dirNum]);
lineDir2Mat = reshape(a2, [1, dirNum]);
lineDir3Mat = reshape(a3, [1, dirNum]);
lineDir4Mat = reshape(a4, [1, dirNum]);
dirMat = [lineDir1Mat; lineDir2Mat; lineDir3Mat; lineDir4Mat];
dirMat = dirMat(:, 2 : end);
dirMat = dirMat ./ sqrt(repmat(sum(dirMat .^ 2, 1), nDims, 1));
% set of start coordinates
x0EllObj = 1E-2 * ell_unitball(4) + x0Vec;
% calculate solvability set
timeVec = [endTime, 0];
rsTubeObj = elltool.reach.ReachContinuous(linSysObj, x0EllObj, dirMat, ...
timeVec, 'isRegEnabled', true, 'isJustCheck', false, 'regTol', 1e-3);
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
% create projection matrix and draw projection on current axis (z_3, z_4)
velBasisMat = [0 0 1 0 ; 0 0 0 1]';
prTubeObj = rsTubeObj.projection(velBasisMat);
prTubeObj.plotByIa();
hold on;
ylabel('z_3'); zlabel('z_4');
title('Elipsoidal reach tube, proj. on subspace [0 0 1 0 ; 0 0 0 1]');
rotate3d on;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
% create projection matrix and draw projection on current axis (z_1, z_2)
velBasisMat = [1 0 0 0 ; 0 1 0 0]';
prTubeObj = rsTubeObj.projection(velBasisMat);
prTubeObj.plotByIa();
hold on;
ylabel('z_1'); zlabel('z_2');
title('Elipsoidal reach tube, proj. on subspace [1 0 0 0 ; 0 1 0 0]');
rotate3d on;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
% create projection matrix and draw projection on current axis (z_1, z_3)
velBasisMat = [1 0 0 0 ; 0 0 1 0]';
prTubeObj = rsTubeObj.projection(velBasisMat);
prTubeObj.plotByIa();
hold on;
ylabel('z_1'); zlabel('z_3');
title('Elipsoidal reach tube, proj. on subspace [1 0 0 0 ; 0 0 1 0]');
rotate3d on;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
% create projection matrix and draw projection on current axis (z_2, z_4)
velBasisMat = [0 1 0 0 ; 0 0 0 1]';
prTubeObj = rsTubeObj.projection(velBasisMat);
prTubeObj.plotByIa();
hold on;
ylabel('z_2'); zlabel('z_4');
title('Elipsoidal reach tube, proj. on subspace [0 1 0 0 ; 0 0 0 1]');
rotate3d on;

0 comments on commit 3c11289

Please sign in to comment.