Creating a PolytopeTo be able to compute discrete equivalents the definition of the problem needs to be put on a form understandable by the toolbox. To this end a polytope data structure is defined, with three basic elements:
Several examples are included in the demo subdirectory as demosimplex*.m/demopolytope*.m and a small example is shown below. Notice that the toolbox initially only supported simplices and this carries over in some of the naming conventions. Example polytope creation (simplex)
%The dimension of the state space s.dim=3; %The vertices s.vertices={[2;2;1],[1;2;1],[1;1;1],[1.3;1.3;2]}; %Helper function simplicial state/input space. If you want to create a %polytope follow the steps shown for the input s=makesimplex(s); %The system dynamics s.dynamics.A=[0 1 0; 0 0 1; 0 0 0]; s.dynamics.B=[0 1; 1 0;0 0 ]; s.dynamics.C=[0;0;0]; %The input space is a 2 dimensional polytope s.input.dim=2; s.input.vertices={[1;0.5],-[1;0.5],[-1;0.5],[1;-0.5]}; %We can't use makesimplex on polytopes so it is created manually %The vertices of facet 1 s.input.facet{1}.vertices={1,3}; %A vertice not belonging to facet 1 s.input.facet{1}.opposit=4; s.input.facet{2}.vertices={1,4}; s.input.facet{2}.opposit=2; s.input.facet{3}.vertices={2,3}; s.input.facet{3}.opposit=1; s.input.facet{4}.vertices={2,4}; s.input.facet{4}.opposit=3; %Prepare the polytope s=preparepolytope(s); When the computations on the simplex are done, some space can be saved by using the function s=cleansimplex(s). |