⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nbhood.m

📁 Lattice coding and decoding
💻 M
字号:
function pts = nbhood(latt,element,varargin)%NBHOOD Find lattice element neighbors%   NH = NBHOOD(L,P) finds the element's P neighbours along the%   equilateral axes. There's a slight difference between NBHOOD and%   SSHELL function. The following examle tells all.%%   Example:%       pts = 2 ^ 5;%       Z2 = makelatt('Z',pts,2);%       NH = nbhood(Z2,13)%       showlatt(NH,'Style',1); hold on;%       showlatt(Z2,'Labeling','num');% %       figure;%       SH = sshell(Z2,13);%       showlatt(SH,'Style',2); hold on;%       showlatt(Z2,'Labeling','num');%%   Note: NBHOOD function gives sensible results only for geometrically%         uniform lattices.%%   See also SSHELL, KISS.%   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>name = 'NBHOOD';[idt,tag] = iecho(name);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY BEGIN %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% set shell thicknessif nargin == 3	thick = varargin{1};else 	thick = 1; % default thickessend[npts,dim] = size(latt);% check the element positionif (npts < element) | (element < 0)	disp(' ');	disp([tag,'Not a lattice element!']);	disp([idt,'Setting element to 1.']);	disp(' ');		element = 1;endcoord = latt(element,:);center = repmat(coord,[npts 1]);dist = abs(latt - center);% find smallest non-zero element% 0 -> realmaxq = mapsto(dist,0,realmax);m = min(min(q));q100 = mapsto(dist,0,100)z = unique(q100)%m = min(min(q));% STEP I: throw out the elements greater than my = (dist <= m);u = prod(y,2);r = find(u == 1);%u = sum(y,2);%r = find(u > 0);% STEP II: find those with zero distance from the rest (lie on the axis)x = (dist == 0);w = sum(x,2);s = find(w > 0); % find the intersection of bothpos = intersect(r,s);% removing query point from the nbhood setpt = find(pos == element);pos = pos([1:pt - 1 pt + 1:end]);pts = latt(pos,:);%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% BODY END %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

⌨️ 快捷键说明

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