help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

axis & randn


From: John Eaton
Subject: axis & randn
Date: Fri, 3 Nov 1995 00:18:59 -0600

Jerry Lynch <address@hidden> wrote:

: will there be a 'randn' function instead of 
: needing to use 'rand'?

Yes, I just updated the random number generator functions to add randn
and use separate generators and seeds for normal and uniform
distributions.

If you're not too picky about whether the two sequences actually use
different generators and seeds, you could use a function like this for
randn:

function y = randn (x1, x2)

  unwind_protect

    save_dist = rand ("dist");
    rand ("normal");

    if (nargin == 0)
      y = rand ();
    elseif (nargin == 1)
      y = rand (x1);
    elseif (nargin == 2)
      y = rand (x1, x2);
    endif

  unwind_protect_cleanup

    rand (save_dist);

  end_unwind_protect

endfunction


: And will the 'v=axis' command return the axis values for the current
: figure?

Here's a patch:

*** scripts/plot/axis.m 1995/06/25 19:56:32
--- scripts/plot/axis.m 1995/11/03 05:56:06
***************
*** 16,22 ****
  # along with Octave; see the file COPYING.  If not, write to the Free
  # Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, 
USA.
  
! function axis (ax)
  
  # usage: axis ()
  #        axis ([xmin, xmax])
--- 16,22 ----
  # along with Octave; see the file COPYING.  If not, write to the Free
  # Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, 
USA.
  
! function curr_axis = axis (ax)
  
  # usage: axis ()
  #        axis ([xmin, xmax])
***************
*** 30,35 ****
--- 30,44 ----
  # If your plot is already drawn, then you need to REPLOT before 
  # the new axis limits will take effect.
  
+ # This may not be correct if someone has used the gnuplot interface
+ # directly...
+ 
+   global __current_axis__;
+ 
+   if (! exist ("__current_axis__"))
+     __current_axis__ = [-10, 10, -10, 10];
+   endif
+ 
    if (nargin > 1)
      usage ("axis ([xmin, xmax, ymin, ymax, zmin, zmax])");
    endif
***************
*** 36,41 ****
--- 45,51 ----
  
    if (nargin == 0)
      set autoscale;
+     curr_axis = __current_axis__;
    elseif (is_vector (ax))
  
      len = length (ax);
***************
*** 44,49 ****
--- 54,61 ----
        error ("axis: expecting vector with 2, 4, or 6 elements");
      endif
  
+     __current_axis__ = reshape (ax, 1, len);
+ 
      if (len > 1)
        eval (sprintf ("set xrange [%g:%g];", ax (1), ax (2)));
      endif


(This also points out that Octave really needs a way to create
`static' variables, but that's a project for another day...)

Thanks,

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]