Mercurial > forge
changeset 8692:43d0eec6a6ac octave-forge
hist2d: help text to texinfo and start use of print_usage
author | carandraug |
---|---|
date | Thu, 27 Oct 2011 15:51:59 +0000 |
parents | acd134f8f6a6 |
children | 75a186750b4a |
files | main/plot/inst/hist2d.m |
diffstat | 1 files changed, 18 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/main/plot/inst/hist2d.m Thu Oct 27 15:45:41 2011 +0000 +++ b/main/plot/inst/hist2d.m Thu Oct 27 15:51:59 2011 +0000 @@ -1,17 +1,22 @@ -% hist2d ([x,y], xbins, ybins, norm) -% Produce a 2D histogram. -% -% Points xi,yi are stored in a 2-column array. -% If ybins is missing, use xbins. -% If bins is a scalar, use that many bins. -% If bins is a vector, it represents bin edges. +## This program is in the public domain +## Authors: Paul Kienzle <pkienzle@users.sf.net> -% Author: Paul Kienzle -% This code is public domain. +## -*- texinfo -*- +## @deftypefn {Function File} {[@var{counts}, @var{xbins}, @var{ybins}] =} hist2d ([@var{x}, @var{y}], @var{xbins}, @var{ybins}, @var{norm}) +## Produce a 2D histogram. +## +## Points xi,yi are stored in a 2-column array. +## If ybins is missing, use xbins. +## If bins is a scalar, use that many bins. +## If bins is a vector, it represents bin edges. +## +## @end deftypefn function [ret_counts, xbins, ybins] = hist2d(M,xbins,ybins) - if nargin < 1 && nargin > 3, usage("[nn,xx,yy] = hist2d (M,x,y)"); end + if nargin < 1 && nargin > 3 + print_usage + end lo = min(M); hi = max(M); @@ -23,13 +28,13 @@ # If n bins, find centers based on n+1 bin edges if isscalar(xbins) - xbins = linspace(lo(1),hi(1),xbins+1); + xbins = linspace(lo(1),hi(1),xbins+1); xbins = (xbins(1:end-1)+xbins(2:end))/2; end if isscalar(ybins) ybins = linspace(lo(2),hi(2),ybins+1); ybins = (ybins(1:end-1)+ybins(2:end))/2; - end + end xcut = (xbins(1:end-1)+xbins(2:end))/2; ycut = (ybins(1:end-1)+ybins(2:end))/2; @@ -42,4 +47,4 @@ else mesh(xbins,ybins,full(counts')); end -end +endfunction