% Input:
% state_id: integer (id of the stored computation state)

% Output:
% success: integer
% results: matrix (containing the results of a flowpipe computation)
% omegas: cell arry or function handles (containing the support functions generated by a flowpipe computation)
% iteration: integer (number of taken transitions)
% time: double (time passed before visiting the location)
% Ijump: matrix (containing the indices of the sets intersecting guards)
% transitiontotake: vector (containing at position x the id of the
%                           transition which has to be taken for the sets in Ijump(x,:)
% qd: matrix (containing column-wise all outgoing transitions from the active location

% Description:
% loads the stored computation state fron global variable stored_states
% with id state_id. If success is 0 there is no stored computation state
% with the specified id

function [success,results,omegas,iteration,time,Ijump,transitiontotake,qd] = load_state(state_id)

global stored_states;

success = 0;
%if state_id > length(stored_states) || state_id < 1 || isempty(stored_states{state_id})
if state_id < 1 || isempty(stored_states) || isempty(stored_states{state_id})
    disp('');
else
    success = 1;
    results = stored_states{state_id}.results;
    omegas = stored_states{state_id}.omegas;
    iteration = stored_states{state_id}.iteration;
    time = stored_states{state_id}.time;
    Ijump = stored_states{state_id}.Ijump;
    transitiontotake = stored_states{state_id}.transitiontotake;
    qd = stored_states{state_id}.qd;
end;