-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcartProd.m
73 lines (59 loc) · 1.3 KB
/
cartProd.m
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
function Z = cartProd(Z1,Z2)
% cartProd - Returns the cartesian product of two zonotopes
%
% Syntax:
% Z = cartProd(Z1,Z2)
%
% Inputs:
% Z1 - zonotope object
% Z2 - zonotope object
%
% Outputs:
% Z - zonotope object
%
% Example:
%
% Other m-files required: none
% Subfunctions: none
% MAT-files required: none
%
% See also: none
% Author: Amr Alanwar
% Written: 16-October-2022
% Last update:
%
% Last revision:---
%------------- BEGIN CODE --------------
if(~isempty(Z1.c) & ~isempty(Z2.c))
newCen = [ Z1.c;Z2.c ];
elseif (isempty(Z1.c) & isempty(Z2.c))
newCen =[];
elseif isempty(Z1.c)
newCen = Z2.c ;
elseif isempty(Z2.c)
newCen = Z1.c ;
end
if(isempty(Z1.G))
newGen = Z2.G;
elseif(isempty(Z2.G))
newGen = Z1.G;
elseif(isempty(Z2.G) & isempty(Z2.G))
newGen ={};
elseif(~isempty(Z2.G) & ~isempty(Z2.G))
g1Len = length(Z1.G);
g2Len = length(Z2.G);
sizeOfGen1 = length(Z1.G{1});
sizeOfGen2 = length(Z2.G{1});
for i =1:g1Len
newGen{i} = [Z1.G{i};zeros(sizeOfGen2,1)];
end
index =1;
for i=g1Len+1:g1Len+g2Len
newGen{i} = [zeros(sizeOfGen1,1);Z2.G{index}];
index = index +1;
end
end
Z=logicalZonotope(newCen,newGen);
Z =unique(Z);
end
%------------- END OF CODE --------------