


Transform absolute index to relative index
-- Syntax
[jx] = vb_index2indexsub(ix, ixsub)
[jx, ix_in_ixsub] = vb_index2indexsub(ix, ixsub)
-- Input
ix : target indices to be transformed
ixsub : indices of sub-region
-- Output
Transform absolute index to index within 'ixsub'
jx : transformed indices w.r.t 'ixsub'
ix_in_ixsub : absolute index included in both 'ixsub' & 'ix'
vertex index in 'ix' which is included in 'ixsub'
ix_in_ixsub = ixsub(jx)
Example.
ix=[1 5 10], ixsub=[5:10],
--> jx = [1 6]
ix_in_ixsub = [5 10]
Modufied by M. Sato 2006/8/20
Input argument 'Nall' is removed.
Nall is automatically calculated.
Copyright (C) 2011, ATR All Rights Reserved.
License : New BSD License(see VBMEG_LICENSE.txt)

0001 function [jx, ix_in_ixsub]= vb_index2indexsub(ix, ixsub) 0002 % Transform absolute index to relative index 0003 % -- Syntax 0004 % [jx] = vb_index2indexsub(ix, ixsub) 0005 % [jx, ix_in_ixsub] = vb_index2indexsub(ix, ixsub) 0006 % -- Input 0007 % ix : target indices to be transformed 0008 % ixsub : indices of sub-region 0009 % 0010 % -- Output 0011 % Transform absolute index to index within 'ixsub' 0012 % jx : transformed indices w.r.t 'ixsub' 0013 % ix_in_ixsub : absolute index included in both 'ixsub' & 'ix' 0014 % vertex index in 'ix' which is included in 'ixsub' 0015 % ix_in_ixsub = ixsub(jx) 0016 % 0017 % Example. 0018 % ix=[1 5 10], ixsub=[5:10], 0019 % --> jx = [1 6] 0020 % ix_in_ixsub = [5 10] 0021 % 0022 % Modufied by M. Sato 2006/8/20 0023 % Input argument 'Nall' is removed. 0024 % Nall is automatically calculated. 0025 % 0026 % Copyright (C) 2011, ATR All Rights Reserved. 0027 % License : New BSD License(see VBMEG_LICENSE.txt) 0028 0029 Nsub = length(ixsub); 0030 Nall = max([ ix(:); ixsub(:) ]); 0031 0032 Itrans = zeros(Nall,1); 0033 Itrans(ixsub) = 1:Nsub; 0034 0035 jx_tmp = Itrans(ix); 0036 jx = find(jx_tmp > 0); 0037 jx = jx_tmp(jx); 0038 0039 ix_in_ixsub = ixsub(jx);