0001 function h = sldrawgraph(G, X, Xt, ppedges, ppsn, pptn)
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
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 if nargin < 2
0051 raise_lackinput('sldrawgraph', 2);
0052 end
0053
0054 EG = sledgeset(G, 'off');
0055 gi = slgraphinfo(EG);
0056 n = gi.n;
0057 nt = gi.nt;
0058
0059 d = size(X, 1);
0060 if ~isnumeric(X) || ndims(X) ~= 2 || (d ~= 2 && d ~= 3)
0061 error('sltoolbox:invalidarg', ...
0062 'The X should be a 2D numeric matrix, and should have 2 or 3 rows.');
0063 end
0064
0065 if nargin < 3 || isempty(Xt)
0066 Xt = X;
0067 bi = false;
0068 else
0069 if ~isnumeric(Xt) || ndims(Xt) ~= 2
0070 error('sltoolbox:invalidarg', ...
0071 'The X should be a 2D numeric matrix, and should have 2 or 3 rows.');
0072 end
0073 if size(Xt, 1) ~= d
0074 error('sltoolbox:sizmismatch', ...
0075 'The sample dimensions in Xt is not the same as X');
0076 end
0077 bi = true;
0078 end
0079
0080 if size(X, 2) ~= n || size(Xt, 2) ~= nt
0081 error('sltoolbox:sizmismatch', ...
0082 'The size of graph is not consistent with the sample numbers');
0083 end
0084
0085
0086 if nargin < 4 || isempty(ppedges)
0087 ppedges = {};
0088 end
0089
0090 if nargin < 5 || isempty(ppsn)
0091 ppsn = {};
0092 end
0093
0094 if nargin < 6 || isempty(pptn)
0095 pptn = ppsn;
0096 end
0097
0098 if nargout >= 1
0099 output_h = true;
0100 else
0101 output_h = false;
0102 end
0103
0104
0105
0106
0107
0108 edges = EG.edges;
0109 edges = slpruneedgeset(n, nt, edges);
0110
0111 I = edges(:,1);
0112 J = edges(:,2);
0113 nedges = length(I);
0114
0115 xc = [X(1, I); Xt(1, J); NaN(1, nedges)];
0116 xc = xc(:);
0117 yc = [X(2, I); Xt(2, J); NaN(1, nedges)];
0118 yc = yc(:);
0119 if d == 3
0120 zc = [X(3, I); Xt(3, J); NaN(1, nedges)];
0121 zc = zc(:);
0122 end
0123
0124
0125
0126
0127 if d == 2
0128 ch = plot(xc, yc, ppedges{:});
0129 else
0130 ch = plot3(xc, yc, zc, ppedges{:});
0131 end
0132 if output_h
0133 h = ch;
0134 end
0135 clear xc yc zc;
0136
0137
0138
0139 if ~isempty(ppsn)
0140 ppsn = [ppsn, {'LineStyle', 'none'}];
0141 hold on;
0142 if d == 2
0143 ch = plot(X(1,:), X(2,:), ppsn{:});
0144 else
0145 ch = plot3(X(1,:), X(2,:), X(3,:), ppsn{:});
0146 end
0147 if output_h
0148 h = [h; ch];
0149 end
0150 end
0151
0152
0153
0154 if bi && ~isempty(pptn)
0155 pptn = [pptn, {'LineStyle', 'none'}];
0156 hold on;
0157 if d == 2
0158 ch = plot(Xt(1,:), Xt(2,:), pptn{:});
0159 else
0160 ch = plot3(Xt(1,:), Xt(2,:), Xt(3,:), pptn{:});
0161 end
0162 if output_h
0163 h = [h; ch];
0164 end
0165 end
0166
0167