-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhancement: change equations, change some labels, variables in code, change title picture
- Loading branch information
1 parent
81d2068
commit dcab2f8
Showing
3 changed files
with
59 additions
and
120 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
103 changes: 35 additions & 68 deletions
103
products/+elltool/+doc/+snip/s_chapter06_section06_snippet01.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,108 +1,75 @@ | ||
|
||
% in this block we initialize all variables for this model | ||
m_1 = 1; | ||
m_2 = 2; | ||
|
||
J_1 = 0; | ||
J_2 = 0; | ||
|
||
phi_10 = 0; | ||
phi_20 = 0; | ||
|
||
L_1 = 5; | ||
L_2 = 5; | ||
|
||
s_1 = 3; | ||
s_2 = 3; | ||
|
||
alpha_1 = 3; | ||
alpha_2 = 10; | ||
|
||
k_1 = 0; | ||
k_2 = 0; | ||
|
||
% initialize all variables for this model | ||
m = [1; 2]; | ||
J = [0; 0]; | ||
phi_0 = [0; 0]; | ||
L = [5; 5]; | ||
s = [3; 3]; | ||
alpha = [3; 10]; | ||
k = [0; 0]; | ||
g = 9.8; | ||
|
||
a_1 = m_1 * s_1^2 + J_1 + m_2 * L_1^2; | ||
a_2 = L_1 * s_2 * cos(phi_10 - phi_20); | ||
b_1 = L_1 * s_2 * cos(phi_10 - phi_20); | ||
b_2 = m_2 * s_2^2 + J_2; | ||
a_1 = m(1) * s(1)^2 + J(1) + m(2) * L(1)^2; | ||
a_2 = L(1) * s(2) * cos(phi_0(1) - phi_0(2)); | ||
b_1 = L(1) * s(2) * cos(phi_0(1) - phi_0(2)); | ||
b_2 = m(2) * s(2)^2 + J(2); | ||
|
||
d_1 = (m_1 * a_1 + m_2 * L_2) * g; | ||
d_2 = m_2 * a_2 * g; | ||
d_1 = (m(1) * a_1 + m(2) * L(2)) * g; | ||
d_2 = m(2) * a_2 * g; | ||
|
||
X_1 = -k_1 * a_2 / (a_2 * b_1 - a_1 * b_2); | ||
X_2 = k_2 * a_1 / (a_2 * b_1 - a_1 * b_2); | ||
X_1 = -k(1) * a_2 / (a_2 * b_1 - a_1 * b_2); | ||
X_2 = k(2) * a_1 / (a_2 * b_1 - a_1 * b_2); | ||
X_3 = a_2 / (a_2 * b_1 - a_1 * b_2); | ||
X_4 = -a_1 / (a_2 * b_1 - a_1 * b_2); | ||
X_5 = -(d_1 * a_2 + d_2 * a_1) / (a_2 * b_1 - a_1 * b_2); | ||
|
||
Y_1 = -k_1 * b_2 / (a_2 * b_1 - a_1 * b_2); | ||
Y_2 = k_2 * b_1 / (a_2 * b_1 - a_1 * b_2); | ||
Y_1 = -k(1) * b_2 / (a_2 * b_1 - a_1 * b_2); | ||
Y_2 = k(2) * b_1 / (a_2 * b_1 - a_1 * b_2); | ||
Y_3 = b_2 / (a_2 * b_1 - a_1 * b_2); | ||
Y_4 = -b_1 / (a_2 * b_1 - a_1 * b_2); | ||
Y_5 = (d_2 * b_1 - d_1 * b_2) / (a_2 * b_1 - a_1 * b_2); | ||
|
||
X_11 = d_1 * a_2 * sin(phi_10) / (a_2 * b_1 - a_1 * b_2); | ||
X_12 = d_2 * a_1 * sin(phi_20) / (a_2 * b_1 - a_1 * b_2); | ||
X_13 = (-d_1 * a_2 * cos(phi_10) - d_1 * a_2 * sin(phi_10) * phi_10) / ... | ||
(a_2 * b_1 - a_1 * b_2) + (-d_2 * a_1 * cos(phi_20) - ... | ||
d_2 * a_1 * sin(phi_20) * phi_20) / (a_2 * b_1 - a_1 * b_2); | ||
X_11 = d_1 * a_2 * sin(phi_0(1)) / (a_2 * b_1 - a_1 * b_2); | ||
X_12 = d_2 * a_1 * sin(phi_0(2)) / (a_2 * b_1 - a_1 * b_2); | ||
X_13 = (-d_1 * a_2 * cos(phi_0(1)) - d_1 * a_2 * sin(phi_0(1)) * phi_0(1)) / ... | ||
(a_2 * b_1 - a_1 * b_2) + (-d_2 * a_1 * cos(phi_0(2)) - ... | ||
d_2 * a_1 * sin(phi_0(2)) * phi_0(2)) / (a_2 * b_1 - a_1 * b_2); | ||
|
||
Y_11 = d_1 * b_2 * sin(phi_10) / (a_2 * b_1 - a_1 * b_2); | ||
Y_12 = -d_2 * b_1 * sin(phi_20) / (a_2 * b_1 - a_1 * b_2); | ||
Y_13 = (d_2 * b_1 * cos(phi_20) + d_2 * b_1 * sin(phi_20) * phi_20) / ... | ||
(a_2 * b_1 - a_1 * b_2) + (-d_1 * b_2 * cos(phi_10) - ... | ||
d_1 * b_2 * sin(phi_10) * phi_10) / (a_2 * b_1 - a_1 * b_2); | ||
Y_11 = d_1 * b_2 * sin(phi_0(1)) / (a_2 * b_1 - a_1 * b_2); | ||
Y_12 = -d_2 * b_1 * sin(phi_0(2)) / (a_2 * b_1 - a_1 * b_2); | ||
Y_13 = (d_2 * b_1 * cos(phi_0(2)) + d_2 * b_1 * sin(phi_0(2)) * phi_0(2)) / ... | ||
(a_2 * b_1 - a_1 * b_2) + (-d_1 * b_2 * cos(phi_0(1)) - ... | ||
d_1 * b_2 * sin(phi_0(1)) * phi_0(1)) / (a_2 * b_1 - a_1 * b_2); | ||
|
||
%initialize A and B relying on theoretical materials | ||
aMat = [0 0 1 0; 0 0 0 1; Y_11 Y_12 Y_1 Y_2; X_11 X_12 X_1 X_2]; | ||
bMat = [0 0 0 0; 0 0 0 0; Y_3 Y_4 0 0 ; X_3 X_4 0 0]; | ||
|
||
x_01=0; | ||
x_02=0; | ||
x_03=0; | ||
x_04=0; | ||
myTime=5; | ||
bMat = [0 0; 0 0; Y_3 Y_4; X_3 X_4]; | ||
|
||
x_0 = [0; 0; 0; 0]; | ||
endTime=5; | ||
% after initializing we create ellipsoid for control function | ||
diagonal = diag([alpha_1, alpha_2, 1, 1]); | ||
uEllObj = ellipsoid(diagonal); | ||
|
||
diagMat = diag([alpha(1), alpha(2)]); | ||
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; | ||
|
||
% end position | ||
x_0v = [x_01; x_02; x_03; x_04]; | ||
|
||
% set of start coordinates | ||
x0EllObj = 1E-2 * ell_unitball(4) + x_0v; | ||
|
||
x0EllObj = 1E-2 * ell_unitball(4) + x_0; | ||
% calculate solvability set | ||
timeVec = [myTime, 0]; | ||
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_1, z_2) | ||
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; |
dcab2f8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please use postfix Vec for vectors (mVec instead of m)? And it seems to me better if you do not use _ in variable names.
Why did you remove the code displaying projection of the tube on (z_1,z_2)?
It is necessary also change the code like diagMat = diag([alpha(1), alpha(2)]) to diagMat=diag(alphaVec) (with alpha renamed to alphaVec).