LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
cartesian.m
1function inspace1 = cartesian(inspace1, inspace2)
2% INSPACE1 = CARTESIAN(INSPACE1, INSPACE2)
3%
4% Cartesian product of two matrices. It replicates elements of the first
5% input matrix and pairs them with each row of the second input matrix.
6%
7% Copyright (c) 2012-2026, Imperial College London
8% All rights reserved.
9
10if nargin<2 && iscell(inspace1)
11 C = inspace1;
12 inspace1 = [];
13 for c=1:length(C)
14 inspace1 = State.cartesian(inspace1, C{c});
15 end
16 return
17end
18
19if isempty(inspace1)
20 inspace1 = inspace2;
21 return
22end
23if isempty(inspace2)
24 return
25end
26
27n1 = size(inspace1,1); m1 = size(inspace1,2);
28n2 = size(inspace2,1); m2 = size(inspace2,2);
29inspace1 = repmat(inspace1, n2, 1);
30
31curStates = 1:n1;
32for s=1:n2
33 inspace1(curStates,(m1+1):(m1+m2)) = repmat(inspace2(s,:),length(curStates),1);
34 curStates = (curStates) + n1;
35end
36end