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