| Description of sldrawellipse |
sldrawellipse
PURPOSE 
SLDRAWELLIPSE Draws an ellipse on current axis
SYNOPSIS 
function h = sldrawellipse(center, shape, n, varargin)
DESCRIPTION 
CROSS-REFERENCE INFORMATION 
This function calls:
- sladdvec SLADDVEC adds a vector to columns or rows of a matrix
- slsymeig SLSYMEIG Compute the eigenvalues and eigenvectors for symmetric matrix
- raise_lackinput RAISE_LACKINPUT Raises an error indicating lack of input argument
This function is called by:
SUBFUNCTIONS 
SOURCE CODE 
0001 function h = sldrawellipse(center, shape, n, varargin)
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 if nargin < 2
0048 raise_lackinput('sldraw_ellipse', 2);
0049 end
0050
0051 if length(center) ~= 2
0052 error('sltoolbox:invaliddims', 'center should be a vector of length 2');
0053 end
0054 center = center(:);
0055
0056 if nargin < 3 || isempty(n)
0057 n = 300;
0058 end
0059
0060
0061
0062 if isnumeric(shape) && length(shape) == 3
0063
0064 [S, R] = get_transform_from_geo(shape(1), shape(2), shape(3));
0065
0066 elseif isnumeric(shape) && isequal(size(shape), [2, 2])
0067
0068 [S, R] = get_transform_from_cov(shape);
0069
0070 elseif iscell(shape) && length(shape) == 2
0071
0072 [S, R] = get_transform_from_cov(shape{1});
0073 S = S * shape{2};
0074
0075 end
0076
0077 T = R * S;
0078
0079
0080
0081
0082 t = linspace(0, 2*pi, n);
0083 X = [cos(t); sin(t)];
0084
0085
0086 X = T * X;
0087 X = sladdvec(X, center, 1);
0088
0089
0090 hold on;
0091 h = plot(X(1,:), X(2,:), varargin{:});
0092
0093
0094
0095
0096 function [S, R] = get_transform_from_geo(a, b, theta)
0097
0098 S = [a 0; 0 b];
0099 R = [cos(theta), -sin(theta); sin(theta), cos(theta)];
0100
0101 function [S, R] = get_transform_from_cov(C)
0102
0103 [S, R] = slsymeig(C);
0104 S = max(S, 0);
0105 S = diag(sqrt(S));
0106
0107
0108
0109
0110
0111
0112
Generated on Wed 20-Sep-2006 12:43:11 by m2html © 2003
|
|