-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetSystemMatrix.m
More file actions
58 lines (44 loc) · 1.9 KB
/
Copy pathgetSystemMatrix.m
File metadata and controls
58 lines (44 loc) · 1.9 KB
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
function [surfaceMatrix, translationMatrix, systemMatrix] = ...
getSystemMatrix(system, distances, ns)
%GETSYSTEMMATRIX will return the system matrix of a system.
%
% [surfaceMatrix, translationMatrix, systemMatrix] = ...
% getSystemMatrix(system, distances, ns)
% check size of the inputs arrays
if size(system,2) ~= size(distances,2)
str = ['Input size of system & distances not Valid. ',...
'Input size(system,2) must be equal size(distances,2).'];
error('getSystemMatrix:InputDataSize',str);
end
if size(distances,2)+1 ~= size(ns,2)
str = ['Input size of ns is not Valid. ',...
'Input size(ns,2) must be equal size(distances,2)+1.'];
error('getSystemMatrix:InputDataSize',str);
end
% create a cell arrays for surface matrices & translation matrices
surfaceMatrix = cell(1,size(system,2)-1);
translationMatrix = cell(1,size(distances,2)-2);
ns = ns(1:end-1);
for iSystem = 1:1:size(system,2)-1
surfaceMatrix{1,iSystem} = [1,...
-((ns(1,iSystem+1)-ns(1,iSystem))/...
system(1,iSystem).radius);0, 1];
end
% compute translation matrices
for iDistance = 2:1:size(distances,2)-1
translationMatrix{1,iDistance-1} = [1, 0;...
distances(1,iDistance)/ns(1,iDistance), 1];
end
% instatiate the system matrix with a identity matrix
systemMatrix = eye(2,2);
for iDistance = size(surfaceMatrix,2):-1:2
systemMatrix = systemMatrix *...
surfaceMatrix{1,iDistance} *...
translationMatrix{1,iDistance-1};
end
% multiply the last surface to the system matrix
systemMatrix = systemMatrix * surfaceMatrix{1,1};
% scale some of the matrix entries
systemMatrix(1,2) = systemMatrix(1,2) * 1e-3;
systemMatrix(2,1) = systemMatrix(2,1) * 1e3;
end