annotate scripts/control/util/axis2dlim.m @ 6518:952c8b00525e

[project @ 2007-04-11 20:50:22 by jwe]
author jwe
date Wed, 11 Apr 2007 20:50:23 +0000
parents 99489e2ffbd4
children 43fc02d57862
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
1 ## Copyright (C) 1998 Auburn University. All rights reserved.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
2 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
3 ## This file is part of Octave.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
4 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
5 ## Octave is free software; you can redistribute it and/or modify it
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
6 ## under the terms of the GNU General Public License as published by the
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
7 ## Free Software Foundation; either version 2, or (at your option) any
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
8 ## later version.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
9 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
10 ## Octave is distributed in the hope that it will be useful, but WITHOUT
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
11 ## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
12 ## FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
13 ## for more details.
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
14 ##
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
15 ## You should have received a copy of the GNU General Public License
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
16 ## along with Octave; see the file COPYING. If not, write to the Free
5307
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5016
diff changeset
17 ## Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
4c8a2e4e0717 [project @ 2005-04-26 19:24:27 by jwe]
jwe
parents: 5016
diff changeset
18 ## 02110-1301 USA.
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
19
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
20 ## -*- texinfo -*-
5314
99489e2ffbd4 [project @ 2005-04-28 02:33:03 by jwe]
jwe
parents: 5307
diff changeset
21 ## @deftypefn {Function File} {} axis2dlim (@var{axdata})
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
22 ## Determine axis limits for 2-D data (column vectors); leaves a 10%
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
23 ## margin around the plots.
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
24 ## Inserts margins of +/- 0.1 if data is one-dimensional
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
25 ## (or a single point).
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
26 ##
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
27 ## @strong{Input}
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
28 ## @table @var
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
29 ## @item axdata
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
30 ## @var{n} by 2 matrix of data [@var{x}, @var{y}].
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
31 ## @end table
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
32 ##
5016
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
33 ## @strong{Output}
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
34 ## @table @var
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
35 ## @item axvec
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
36 ## Vector of axis limits appropriate for call to @command{axis} function.
bdbee5282954 [project @ 2004-09-22 02:50:35 by jwe]
jwe
parents: 3500
diff changeset
37 ## @end table
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
38 ## @end deftypefn
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
39
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
40 function axvec = axis2dlim (axdata)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
41
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
42 if(isempty(axdata))
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
43 axdata = 0;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
44 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
45
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
46 ## compute axis limits
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
47 minv = min(axdata);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
48 maxv = max(axdata);
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
49 delv = (maxv-minv)/2; # breadth of the plot
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
50 midv = (minv + maxv)/2; # midpoint of the plot
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
51 axmid = [midv(1), midv(1), midv(2), midv(2)];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
52 axdel = [-0.1, 0.1,-0.1,0.1]; # default plot width (if less than 2-d data)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
53 if(max(delv) == 0)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
54 if(midv(1) != 0)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
55 axdel(1:2) = [-0.1*midv(1),0.1*midv(1)];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
56 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
57 if(midv(2) != 0)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
58 axdel(3:4) = [-0.1*midv(2),0.1*midv(2)];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
59 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
60 else
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
61 ## they're at least one-dimensional
6518
952c8b00525e [project @ 2007-04-11 20:50:22 by jwe]
jwe
parents: 5314
diff changeset
62 tolv = max(1e-8, 1e-8*abs(midv));
952c8b00525e [project @ 2007-04-11 20:50:22 by jwe]
jwe
parents: 5314
diff changeset
63 if(abs(delv(1)) >= tolv(1))
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
64 if(delv(1) != 0)
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
65 axdel(1:2) = 1.1*[-delv(1),delv(1)];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
66 endif
6518
952c8b00525e [project @ 2007-04-11 20:50:22 by jwe]
jwe
parents: 5314
diff changeset
67 if(abs(delv(2)) >= tolv(2))
3431
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
68 axdel(3:4) = 1.1*[-delv(2),delv(2)];
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
69 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
70 endif
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
71 axvec = axmid + axdel;
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
72 endfunction
99ab64f4a09d [project @ 2000-01-14 03:53:03 by jwe]
jwe
parents:
diff changeset
73