source:
MML/trunk/machine/SOLEIL/StorageRing/insertions/idAuxFindClosestElemInd.m
@
4
Last change on this file since 4 was 4, checked in by , 11 years ago | |
---|---|
File size: 301 bytes |
Line | |
---|---|
1 | function indClosestElem = idAuxFindClosestElemInd(valElem, vToCheck) |
2 | |
3 | numElem = length(vToCheck); |
4 | minAbsDif = 1e+23; |
5 | indClosestElem = -1; |
6 | for i = 1:numElem |
7 | curAbsDif = abs(vToCheck(i) - valElem); |
8 | if(minAbsDif > curAbsDif) |
9 | minAbsDif = curAbsDif; |
10 | indClosestElem = i; |
11 | end |
12 | end |
Note: See TracBrowser
for help on using the repository browser.