0001 function hist2dot(h, filename)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025 fd = fopen(filename, 'w+');
0026
0027
0028 fprintf(fd, 'digraph G \n{\n');
0029
0030 [n,a, nodes] = getNodes(h, [], 0, 1, []);
0031
0032
0033 fprintf(fd, 'end [label="END"];\n');
0034 for j=1:length(nodes)
0035 node = nodes(j);
0036
0037
0038 fcn = node.names;
0039 shape = 'rectangle';
0040 fsize = 12;
0041 Opsize = 24;
0042 opextras = 'style=filled, fillcolor=gray90 fixedsize=true width=0.5';
0043 extras = '';
0044 switch fcn
0045 case 'times'
0046 fcn = '*';
0047 shape = 'circle';
0048 fsize = Opsize;
0049 extras = opextras;
0050 case 'mtimes'
0051 fcn = '.*';
0052 shape = 'circle';
0053 fsize = Opsize;
0054 extras = opextras;
0055 case 'plus'
0056 fcn = '+';
0057 shape = 'circle';
0058 fsize = Opsize;
0059 extras = opextras;
0060 case 'minus'
0061 fcn = '-';
0062 shape = 'circle';
0063 fsize = Opsize;
0064 extras = opextras;
0065 case 'rdivide'
0066 fcn = './';
0067 shape = 'circle';
0068 fsize = Opsize;
0069 extras = opextras;
0070 case 'mrdivide'
0071 fcn = '/';
0072 shape = 'circle';
0073 fsize = Opsize;
0074 extras = opextras;
0075 end
0076
0077 wstr = wrapstring([fcn char(node.params)], 10);
0078 ss = '';
0079 for s=wstr
0080 ss = [ss '\n' char(s)];
0081 end
0082 ss = ss(3:end);
0083 fprintf(fd, '%s_%d [%s fontsize=%d shape=%s label="%s"];\n', node.names, j, extras, fsize, shape, ss);
0084 end
0085
0086
0087 fprintf(fd, '\n');
0088 fprintf(fd, '\n');
0089
0090 for j=length(nodes):-1:1
0091
0092 node = nodes(j);
0093 if node.pn > 0
0094 dst = nodes(node.pn);
0095 fprintf(fd, '%s_%d -> %s_%d;\n', node.names, j, dst.names, dst.n);
0096 else
0097 fprintf(fd, '%s_%d -> end;\n', node.names, j);
0098 end
0099
0100 end
0101
0102
0103
0104 fprintf(fd, '}\n');
0105
0106
0107 fclose(fd);
0108