[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
rlocus/gnuplot problem
From: 
John W. Eaton 
Subject: 
rlocus/gnuplot problem 
Date: 
Tue, 10 Apr 2007 16:32:26 0400 
On 10Apr2007, A. Scottedward Hodel wrote:
 I'm using the recently updated rlocus function in octave 2.9.10 and
 have found a problem that I don't know how to fix.
 octave:2> rlocus(tf(1,[1,2,10]))
 ans = [](0x0)
 octave:3>
 gnuplot> plot "" using ($1):($2) title "" with lines linestyle 1,
 "" using ($1):($2) title "asymptotes" with lines linestyle 2, ""
 using ($1):($2) title "locus" with lines linestyle 3, "" using ($1):
 ($2) title "" with lines linestyle 4, "" using ($1):($2) title "open
 loop poles" with points linestyle 5;




 ^
 line 462: Can't plot with an empty x range!

 The problem occurs when replotting with title, xlabel, or ylabel
 commands. The error message above is not an artifiact; the root
 locus in this case is indeed a pair of vertical lines that go outward
 from poles at 1 +/ j3. It appears to be a problem interfacing to
 gnuplot, and that's where I get stuck.

 Can someone duplicate this problem and, if so, how can I go about
 fixing it?
I think the problem is the call to axis in rlocus.m. The limits are
computed by control/util/axis2dlim.m and that doesn't seem to be
handling values that are almost but not exactly equal.
Commenting out the call to axis in rlocus.m won't quite work becuase
of a similar bug in the get_axis_limits function in
plot/__go_draw_axes__.m. I checked in the following patch for that
bug.
What would you like to do with rlocus.m and axis2dlim.m?
jwe
scripts/ChangeLog:
20070410 John W. Eaton <address@hidden>
* plot/__go_draw_axes__.m: Try harder to handle min and max vals
that are close but not exactly equal.
Index: scripts/plot/__go_draw_axes__.m
===================================================================
RCS file: /cvs/octave/scripts/plot/__go_draw_axes__.m,v
retrieving revision 1.14
diff u u r1.14 __go_draw_axes__.m
 scripts/plot/__go_draw_axes__.m 9 Apr 2007 23:15:47 0000 1.14
+++ scripts/plot/__go_draw_axes__.m 10 Apr 2007 20:31:24 0000
@@ 707,9 +707,10 @@
endif
warning ("axis: omitting negative data in log plot");
endif
 if (min_val == max_val)
 min_val = 0.9 * min_val;
 max_val = 1.1 * max_val;
+ ## FIXME  maybe this test should also be relative?
+ if (abs (min_val  max_val) < sqrt (eps))
+ min_val *= 0.9;
+ max_val *= 1.1;
endif
min_val = 10 ^ floor (log10 (min_val));
max_val = 10 ^ ceil (log10 (max_val));
@@ 717,9 +718,10 @@
if (min_val == 0 && max_val == 0)
min_val = 1;
max_val = 1;
 elseif (min_val == max_val)
 min_val = 0.9 * min_val;
 max_val = 1.1 * max_val;
+ ## FIXME  maybe this test should also be relative?
+ elseif (abs (min_val  max_val) < sqrt (eps))
+ min_val = 0.1 * abs (min_val);
+ max_val += 0.1 * abs (max_val);
endif
## FIXME  to do a better job, we should consider the tic spacing.
scale = 10 ^ floor (log10 (max_val  min_val)  1);