1function tranSysState = sampleSys(self, numSamples, markActivePassive)
2% TRANSYSSTATE = SAMPLESYS(NUMSAMPLES)
3options = self.getOptions;
5if GlobalConstants.DummyMode
10if nargin>=2 %exist(
'numSamples',
'var')
11 options.samples = numSamples;
13 numSamples = options.samples;
17 markActivePassive = false;
21 case {
'default',
'serial'}
22 options.method =
'serial'; % nrm does not support tran*
23 [~, tranSystemState, tranSync] = self.runAnalyzer(options);
25 tranSysState =
struct();
26 tranSysState.handle = self.model.getStatefulNodes
';
27 tranSysState.t = tranSystemState{1};
28 tranSysState.state = {tranSystemState{2:end}};
29 tranSysState.event = tranSync;
30 event = tranSysState.event;
32 for i=1:size(tranSysState.state,2)
33 if size(tranSysState.state{i},1) > numSamples
34 tranSysState.t = tranSystemState(1:numSamples);
35 tranSysState.state = tranSysState.state{i}(1:numSamples,:);
39 tranSysState.event = {};
40 for e = 1:length(event)
41 for a=1:length(sn.sync{event(e)}.active)
42 tranSysState.event{end+1} = sn.sync{event(e)}.active{a};
43 tranSysState.event{end}.t = tranSysState.t(e);
45 for p=1:length(sn.sync{event(e)}.passive)
46 tranSysState.event{end+1} = sn.sync{event(e)}.passive{p};
47 tranSysState.event{end}.t = tranSysState.t(e);
50 tranSysState.isaggregate = false;
52 line_error(mfilename,'sampleSys
is not available in SolverSSA with the chosen method.
');
56 apevent = cell(1,length(tranSysState.t)-1);
57 for ti = 1:length(apevent)
58 apevent{ti} = struct('active
',[],'passive
',[]);
60 for e=1:length(tranSysState.event)
61 ti = find(tranSysState.event{e}.t == tranSysState.t);
62 if ~isempty(ti) && ti<length(tranSysState.t)
63 switch tranSysState.event{e}.event
65 apevent{ti}.passive = tranSysState.event{e};
67 apevent{ti}.active = tranSysState.event{e};
71 tranSysState.event = apevent';