1% ImageFromDMMAP(D, outFileName, prec)
3% Depicts the given discrete marked Markovian arrival
4% process, and either displays it or saves it to file.
8% D : list of matrices of shape(M,M), length(N)
9% The D0...DN matrices of the DMMAP
10% outFileName : string, optional
11% If it
is not provided, or equals to
'display', the
12% image
is displayed on the screen, otherwise it
is
13% written to the file. The file format
is deduced
15% prec : double, optional
16% Transition probabilities less then prec are
17% considered to be zero and are left out from the
18% image. The
default value
is 1e-13.
22% The
'graphviz' software must be installed and available
23% in the path to use
this feature.
25function ImageFromDMMAP(D,outFileName,prec)
27 global BuToolsCheckInput;
28 if isempty(BuToolsCheckInput)
29 BuToolsCheckInput =
true;
32 if BuToolsCheckInput && ~CheckDMMAPRepresentation(D)
33 error(
'ImageFromDMMAP: Input isn''t a valid DMMAP representation!');
36 if ~exist(
'prec',
'var')
40 if ~exist('outFileName','var') || strcmp(outFileName,'display')
41 outputFile = '.result.png';
44 outputFile = outFileName;
48 inputFile = '.temp.dot';
50 fid = fopen(inputFile,'w');
51 fprintf(fid, 'digraph G {\n
');
52 fprintf(fid, '\trankdir=LR;\n
');
53 fprintf(fid, '\tnode [shape=circle,width=0.3,height=0.3,label=
""];\n
');
57 % transitions without arrivals
62 fprintf(fid, '\tn%d -> n%d [label=
"%g"];\n
', i, j, Dx(i,j));
67 % transitions with arrivals
74 fprintf(fid, '\tn%d -> n%d [style=
"dashed",label=
"%g"];\n
', i, j, Dx(i,j));
76 fprintf(fid, '\tn%d -> n%d [style=
"solid",fontcolor=
"/dark28/%d",color=
"/dark28/%d",label=
"%g"];\n
', i, j, min(k-1,8), min(k-1,8), Dx(i,j));
85 [~,~,ext] = fileparts(outputFile);
86 system(['dot -T
', ext(2:end), ' ', inputFile, ' -o
', outputFile]);
91 RGB = imread(outputFile);
92 figure('toolbar
','none
','units
','pixel
','position
',[0,0,size(RGB,2)+100,size(RGB,1)+100]);