1function inspace1 = cartesian(inspace1, inspace2)
2% INSPACE1 = CARTESIAN(INSPACE1, INSPACE2)
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.
7% Copyright (c) 2012-2026, Imperial College London
10if nargin<2 && iscell(inspace1)
14 inspace1 = State.cartesian(inspace1, C{c});
27n1 = size(inspace1,1); m1 = size(inspace1,2);
28n2 = size(inspace2,1); m2 = size(inspace2,2);
29inspace1 = repmat(inspace1, n2, 1);
33 inspace1(curStates,(m1+1):(m1+m2)) = repmat(inspace2(s,:),length(curStates),1);
34 curStates = (curStates) + n1;