0001 function varargout = hist2dot(varargin)
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 VERSION = '$Id: hist2dot.m,v 1.4 2008/02/12 22:30:27 hewitson Exp $';
0024 CATEGORY = 'Output';
0025
0026
0027 if nargin == 2
0028 if isa(varargin{1}, 'history') && ischar(varargin{2})
0029 in = char(varargin{2});
0030 if strcmp(in, 'Params')
0031 varargout{1} = plist;
0032 return
0033 elseif strcmp(in, 'Version')
0034 varargout{1} = VERSION;
0035 return
0036 elseif strcmp(in, 'Category')
0037 varargout{1} = CATEGORY;
0038 return
0039 end
0040 end
0041 end
0042
0043
0044 h = varargin{1};
0045 filename = varargin{2};
0046
0047
0048
0049
0050 fd = fopen(filename, 'w+');
0051
0052
0053 fprintf(fd, 'digraph G \n{\n');
0054
0055 [n,a, nodes] = getNodes(h, [], 0, 1, []);
0056
0057
0058 fprintf(fd, 'end [label="END"];\n');
0059 for j=1:length(nodes)
0060 node = nodes(j);
0061
0062
0063 fcn = node.names;
0064 shape = 'rectangle';
0065 fsize = 12;
0066 Opsize = 24;
0067 opextras = 'style=filled, fillcolor=gray90 fixedsize=true width=0.5';
0068 extras = '';
0069 switch fcn
0070 case 'times'
0071 fcn = '*';
0072 shape = 'circle';
0073 fsize = Opsize;
0074 extras = opextras;
0075 case 'mtimes'
0076 fcn = '.*';
0077 shape = 'circle';
0078 fsize = Opsize;
0079 extras = opextras;
0080 case 'plus'
0081 fcn = '+';
0082 shape = 'circle';
0083 fsize = Opsize;
0084 extras = opextras;
0085 case 'minus'
0086 fcn = '-';
0087 shape = 'circle';
0088 fsize = Opsize;
0089 extras = opextras;
0090 case 'rdivide'
0091 fcn = './';
0092 shape = 'circle';
0093 fsize = Opsize;
0094 extras = opextras;
0095 case 'mrdivide'
0096 fcn = '/';
0097 shape = 'circle';
0098 fsize = Opsize;
0099 extras = opextras;
0100 end
0101
0102 wstr = wrapstring([fcn char(node.params)], 10);
0103 ss = '';
0104 for s=wstr
0105 ss = [ss '\n' char(s)];
0106 end
0107 ss = ss(3:end);
0108 fprintf(fd, '%s_%d [%s fontsize=%d shape=%s label="%s"];\n', node.names, j, extras, fsize, shape, ss);
0109 end
0110
0111
0112 fprintf(fd, '\n');
0113 fprintf(fd, '\n');
0114
0115 for j=length(nodes):-1:1
0116
0117 node = nodes(j);
0118 if node.pn > 0
0119 dst = nodes(node.pn);
0120 fprintf(fd, '%s_%d -> %s_%d;\n', node.names, j, dst.names, dst.n);
0121 else
0122 fprintf(fd, '%s_%d -> end;\n', node.names, j);
0123 end
0124
0125 end
0126
0127
0128
0129 fprintf(fd, '}\n');
0130
0131
0132 fclose(fd);
0133