LINE Solver
MATLAB API documentation
Loading...
Searching...
No Matches
sampleSys.m
1function tranSysState = sampleSys(self, numSamples, markActivePassive)
2% TRANSYSSTATE = SAMPLESYS(NUMSAMPLES)
3options = self.getOptions;
4
5if GlobalConstants.DummyMode
6 tranSysState = NaN;
7 return
8end
9
10if nargin>=2 %exist('numSamples','var')
11 options.samples = numSamples;
12else
13 numSamples = options.samples;
14end
15
16if nargin<3
17 markActivePassive = false;
18end
19
20switch options.method
21 case {'default','serial'}
22 options.method = 'serial'; % nrm does not support tran*
23 [~, tranSystemState, tranSync] = self.runAnalyzer(options);
24
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;
31
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,:);
36 end
37 end
38 sn = self.getStruct;
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);
44 end
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);
48 end
49 end
50 tranSysState.isaggregate = false;
51 otherwise
52 line_error(mfilename,'sampleSys is not available in SolverSSA with the chosen method.');
53end
54
55if markActivePassive
56 apevent = cell(1,length(tranSysState.t)-1);
57 for ti = 1:length(apevent)
58 apevent{ti} = struct('active',[],'passive',[]);
59 end
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
64 case EventType.ARV
65 apevent{ti}.passive = tranSysState.event{e};
66 otherwise
67 apevent{ti}.active = tranSysState.event{e};
68 end
69 end
70 end
71 tranSysState.event = apevent';
72end
73
74end