X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=CreaPhase.git;a=blobdiff_plain;f=octave_packages%2Fcontrol-2.3.52%2F__axis_margin__.m;fp=octave_packages%2Fcontrol-2.3.52%2F__axis_margin__.m;h=a967782346f22f5d1d9f2ff4c04cf2ec7c345886;hp=0000000000000000000000000000000000000000;hb=f5f7a74bd8a4900f0b797da6783be80e11a68d86;hpb=1705066eceaaea976f010f669ce8e972f3734b05 diff --git a/octave_packages/control-2.3.52/__axis_margin__.m b/octave_packages/control-2.3.52/__axis_margin__.m new file mode 100644 index 0000000..a967782 --- /dev/null +++ b/octave_packages/control-2.3.52/__axis_margin__.m @@ -0,0 +1,63 @@ +## Copyright (C) 1998, 2000, 2004, 2005, 2007 +## Auburn University. All rights reserved. +## +## +## This program is free software; you can redistribute it and/or modify it +## under the terms of the GNU General Public License as published by +## the Free Software Foundation; either version 3 of the License, or (at +## your option) any later version. +## +## This program is distributed in the hope that it will be useful, but +## WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +## General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with this program; see the file COPYING. If not, see +## . + +## -*- texinfo -*- +## @deftypefn {Function File} {} __axis_margin__ (@var{axdata}) +## Determine axis limits for 2-D data (column vectors); leaves a 10% +## margin around the plots. +## Inserts margins of +/- 0.1 if data is one-dimensional +## (or a single point). +## +## @strong{Input} +## @table @var +## @item axdata +## @var{n} by 2 matrix of data [@var{x}, @var{y}]. +## @end table +## +## @strong{Output} +## @table @var +## @item axvec +## Vector of axis limits appropriate for call to @command{axis} function. +## @end table +## @end deftypefn + +function axvec = __axis_margin__ (axdata) + + ## compute axis limits + minv = axdata(1); + maxv = axdata(2); + delv = (maxv-minv)/2; # breadth of the plot + midv = (minv + maxv)/2; # midpoint of the plot + axmid = [midv, midv]; + axdel = [-0.1, 0.1]; # default plot width (if less than 2-d data) + + if (delv == 0) + if (midv != 0) + axdel = [-0.1*midv, 0.1*midv]; + endif + else + ## they're at least one-dimensional + tolv = max(1e-8, 1e-8*abs(midv)); + if (abs (delv) >= tolv) + axdel = 1.1*[-delv,delv]; + endif + endif + + axvec = axmid + axdel; + +endfunction