edges_from_samples.m
来自「基于Matlab的地震数据处理显示和测井数据显示于处理的小程序」· M 代码 · 共 37 行
M
37 行
function [edges,newsamples]=edges_from_samples(samples,no_of_bins,fraction)% Compute "no_of_bins" bin edges in such a way that "percentile" samples are % in these bins and that each bin contains about the same number of samples% Written by: E. R.: February 10, 2004% Last updated:% % [edges,newsamples]=edges_from_samples(samples,no_of_bins,fraction)% INPUT% samples samples for which to compute bins% no_of_bins number of bins to compute% fraction fraction of the samples to use; this allows exclusion of outliers% OUTPUT% edges edges of the bins; the number of edges is no_of_bins + 1% newsamples samples retained[samples,ndims]=shiftdim(samples(~isnan(samples))); % Make sure that first % dimension is not singletonnsamp=length(samples);newsamples=sort(samples);if fraction < 1 newnsamp=round(fraction*nsamp); if newnsamp < nsamp % find the range of samples to keep test=newsamples(newnsamp+1:end)-newnsamp(1:nsamp-newnsamp); [dummy,idx]=min(test); newsamples=newsamples(idx:newnsamp+idx-1); end edges=[newsamples(1);newsamples(round((1:no_of_bins)*newnsamp/no_of_bins))];else edges=[newsamples(1);newsamples(round((1:no_of_bins)*nsamp/no_of_bins))];endedges(end)=edges(end)*(1+eps);newsamples=shiftdim(newsamples,-ndims); % Undo dimension change, if there was one
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?