0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 function varargout = hist2dot(varargin)
0027
0028
0029 if utils.helper.isinfocall(varargin{:})
0030 varargout{1} = getInfo(varargin{3});
0031 return
0032 end
0033
0034
0035 h = varargin{1};
0036 filename = varargin{2};
0037
0038
0039
0040
0041 fd = fopen(filename, 'w+');
0042
0043
0044 fprintf(fd, 'digraph G \n{\n');
0045
0046 [n,a, nodes] = getNodes(h, [], 0, 1, []);
0047
0048
0049 fprintf(fd, 'end [label="END"];\n');
0050 for j=1:length(nodes)
0051 node = nodes(j);
0052
0053
0054 fcn = node.names;
0055 shape = 'rectangle';
0056 fsize = 12;
0057 Opsize = 24;
0058 opextras = 'style=filled, fillcolor=gray90 fixedsize=true width=0.5';
0059 extras = '';
0060 switch fcn
0061 case 'times'
0062 fcn = '*';
0063 shape = 'circle';
0064 fsize = Opsize;
0065 extras = opextras;
0066 case 'mtimes'
0067 fcn = '.*';
0068 shape = 'circle';
0069 fsize = Opsize;
0070 extras = opextras;
0071 case 'plus'
0072 fcn = '+';
0073 shape = 'circle';
0074 fsize = Opsize;
0075 extras = opextras;
0076 case 'minus'
0077 fcn = '-';
0078 shape = 'circle';
0079 fsize = Opsize;
0080 extras = opextras;
0081 case 'rdivide'
0082 fcn = './';
0083 shape = 'circle';
0084 fsize = Opsize;
0085 extras = opextras;
0086 case 'mrdivide'
0087 fcn = '/';
0088 shape = 'circle';
0089 fsize = Opsize;
0090 extras = opextras;
0091 end
0092
0093 wstr = utils.prog.wrapstring([fcn char(node.params)], 10);
0094 ss = '';
0095 for s=wstr
0096 ss = [ss '\n' char(s)];
0097 end
0098 ss = ss(3:end);
0099 fprintf(fd, '%s_%d [%s fontsize=%d shape=%s label="%s"];\n', node.names, j, extras, fsize, shape, ss);
0100 end
0101
0102
0103 fprintf(fd, '\n');
0104 fprintf(fd, '\n');
0105
0106 for j=length(nodes):-1:1
0107
0108 node = nodes(j);
0109 if node.pn > 0
0110 dst = nodes(node.pn);
0111 fprintf(fd, '%s_%d -> %s_%d;\n', node.names, j, dst.names, dst.n);
0112 else
0113 fprintf(fd, '%s_%d -> end;\n', node.names, j);
0114 end
0115
0116 end
0117
0118
0119
0120 fprintf(fd, '}\n');
0121
0122
0123 fclose(fd);
0124
0125 end
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143 function ii = getInfo(varargin)
0144 if nargin == 1 && strcmpi(varargin{1}, 'None')
0145 sets = {};
0146 pl = [];
0147 else
0148 sets = {'Default'};
0149 pl = getDefaultPlist;
0150 end
0151
0152 ii = minfo(mfilename, 'history', '', utils.const.categories.output, '$Id: hist2dot.m,v 1.6 2008/09/04 15:29:30 ingo Exp $', sets, pl);
0153 end
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166 function plo = getDefaultPlist()
0167 plo = plist();
0168 end
0169