zhist.m

来自「Lattice coding and decoding」· M 代码 · 共 46 行

M
46
字号
function varargout = zhist(x);%ZHIST Integer histogram%   ZHIST(X) plots the histogram of the vector x; x must be all integer%   vector.%%   [Y,Z] = ZHIST(X) returns unique vector Y of vector X; Z is the%   vector of counts of X.%%   [Y,Z,H] = ZHIST(X) same as above, but also gives uniqe vector of%   histogram values H.%%   Example:%       x = [-1 -1 -2 0 1 1 2 2 3 9 14 23 14 11 31 31 31 22 22 22]';%       zhist(x)%       [y,z,h] = zhist(x)%%   See also HIST, UNIQUE.%   Copyright 2001-2003 Kamil Anis, anisk@feld.cvut.cz%   Dept. of Radioelectronics, %   Faculty of Electrical Engineering%   Czech Technical University in Prague%   $Revision: 0.1 $  $Date: 2003/1/16 17:33:28 $%   --%   <additional stuff goes here>m1 = min(x);m2 = max(x);bins = [m1:m2 + 1];h = hist(x,bins);x_counts = h(find(h ~= 0))';x_unique = unique(x);h_unique = unique(h)';if nargout == 0	bar(x_unique,x_counts);	set(gca,'XTick',x_unique,'YTick',h_unique);else	varargout = {x_unique,x_counts,h_unique};end

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?