Plotting Functions

plotdisceq
% PLOTDISCEQ plots a discrete equivalent of a polytope using colours to mark
% the properties of the facet: Blocked = black, uncontrollable=yellow and
% desired exit facet = green.
%
% Usage H=PLOTDISCEQ(S,DE,OUT,CTRL,FHANDLE)
%
% S is the polytope being plottet
% DE is the discrete equivalent to be plottet
% OUT is an optional the intended exit facet
% CTRL is optional control on the polytope u=CTRL.K*x+CTRL.g
% FHANDLE is an optional handle to the figure to be plottet on
%
% Example:

 s=demosimplex();
 s=preparepolytope(s);
 de=finddiscreteeq(s);
 out=de.exits(1);
 ct=findctrl(s,de,out,@findminsqinput);
 h=plotdisceq(s,de,out,ct);

% See also GETDISCRETEEQ, PLOTMCSIM
plotmcsim
% PLOTCSIM plots Monte Carlo simulations on a polytope using the control
% law given by a discrete equivalent and desired exit facet.
%
% Usage: H=PLOTMCSIM(S,CTRL,FHANDLE,SIMS,TIME,SEED)
%
% S is the affine system on a polytope to be simulated
% CTRL.K and CTRL.G are the control gains used as u=Kx+G
% FHANDLE is an optional figure handle to draw on.
% The following parameters are optional but can also be set from the
% configuration file.
% SIMS is the number of simulations to perform
% TIME is the simulation time given as an interval, see ODE45
% SEED is parsed to the rng, see RAND
%
% H is the figure handle of the figure being drawn on
%
% Example:

 s=demosimplex();
 s=preparepolytope(s);
 de=finddiscreteeq(s);
 out=de.exits(1);
 ct=findctrl(s,de,out,@findminsqinput);
 h=plotdisceq(s,de,out,ct);
 plotmcsim(s,ct,h);

% See also FINDCTRL, PLOTDISCEQ, FIGURE, RAND, ODE45
plotpahs
% PLOTPAHS plots a 2D pahs optionally including, requirements,
% specifications or simulation traces.
%
% Usage: [FIGS]=PLOTPAHS(PAHS,REQ,SPEC,X,T,EVENTS,M0)
%
% PAHS is the pahs to be plottet
% REQ is the requirements, if empty it will not be plottet
% SPEC (optional 1) is the specification on the corresponding discrete abstraction
% X (optional 2) is the trace of a simulation
% T (optional 2) is the time vector corresponding to the entries in X
% EVENTS (optional 2) is the event times, see SIMPAHS
% M0 (optional 2) is the initial mode
%
% FIGS is a cell array of figure handles for the figures being drawn on
%
% Example:

 pahs=demopahs2();
 dgabs=finddiscgame(pahs);
 req=demoreq2();
 spec=req2spec(pahs,req);
 [win,sol]=finddgsol(dgabs,spec);
 if(win)
    disp('Winning')
    ctcat=sol2ctrl(pahs,dgabs,sol);
    l0=req.init{1}.loc;
    m0=req.init{1}.modes(1);
    x0=mean(horzcat(pahs.mode{m0}.loc{l0}.s.vertices{:}),2);
    events{1}.time=3;
    events{1}.mode=2;
    simtime=1000;
    step=.5;
    [x,t,m,l]=simpahs(pahs,ctcat,x0,l0,m0,simtime,events,step);

    plotpahs(pahs,req,x,t,events,m0);
 end

% See also SIMPAHS and REQ2SPEC