Skip to content

Commit

Permalink
Create histogram.m
Browse files Browse the repository at this point in the history
  • Loading branch information
wschwanghart committed Dec 1, 2020
1 parent f26d7f6 commit 4fd1627
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions @GRIDobj/histogram.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
function h = histogram(varargin)

%HISTOGRAM Plot frequency distribution of values in GRIDobj
%
% Syntax
%
% histogram(DEM)
% histogram(DEM,...)
% h = ...
%
% Description
%
% HISTOGRAM overloads MATLAB's histogram function for GRIDobjs. Please
% read the help for this function for details.
%
% Examples
%
% DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
% histogram(DEM)
%
%
% See also: GRIDobj
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 1. December, 2020

ixarg = cellfun(@(x) isa(x,'GRIDobj'),varargin,'UniformOutput',true);
DEM = varargin{ixarg};
z = DEM.Z;
if isfloat(z)
z(isnan(z) | isinf(z)) = [];
end

z = z(:);
varargin{ixarg} = z;

htemp = histogram(varargin{:});
if nargout == 1
h = htemp;
end

0 comments on commit 4fd1627

Please sign in to comment.