📄 hist_2d.m
字号:
function hist_2D(x,y,K); % HIST_2D Two-dimensional histogram.% HIST_2D(X,Y,K) bins the two-dimensional density of scalar time series % X and Y into a KxK equally spaced matrix.% By default K is square root of time series length% Copyright (c) 2002-2003% Andre Sitz, Norbert Marwan, Potsdam University, Germany% http://www.agnld.uni-potsdam.de%% Last Revision: 2002-03-20% Version: 2.3%% 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 2% of the License, or any later version.%% last modified 30.11.04 by Max Logunov if nargin<3 nbin=ceil(length(x)^0.5);elseif nargin==3 nbin=K;end%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%x1=(x-min(x))/max(x-min(x))-eps;y1=(y-min(y))/max(y-min(y))-eps;temp=fix(x1*nbin)+(fix(y1*nbin))*nbin;figure('Name','2D Histogram',... 'NumberTitle','off','color',[1 1 1]);p=histc(temp,0:(nbin^2-1))';p2=reshape(p,nbin,nbin)/length(x);minx = min(min(x)); maxx = max(max(x));if minx == maxx, minx = minx - floor(nbin/2) - 0.5; maxx = maxx + ceil(nbin/2) - 0.5; endminy = min(min(y)); maxy = max(max(y));if miny == maxy, miny = miny - floor(nbin/2) - 0.5; maxy = maxy + ceil(nbin/2) - 0.5; endbins(1,:)=minx:(maxx-minx)/(nbin-1):maxx+eps;bins(2,:)=miny:(maxy-miny)/(nbin-1):maxy+eps;bar3(bins(2,:),p2')dhy=bins(2,2)-bins(2,1);set(gca,'xlim',[0 nbin+1-.1],'ylim',[bins(2,1)-dhy bins(2,end)+dhy])hx=get(gca,'xtick'); dhx=diff(hx); set(gca,'xtick',[1:dhx(1):nbin+1])if dhx>1tx=num2str(fix(100*[bins(1,1):(bins(1,end)-bins(1,1))/(length(hx)-1):bins(1,end)]')/100);elsetx=num2str(fix(100*[bins(1,:)]')/100);endset(gca,'xticklabel',tx,'fontsize',8);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -