You're missing some things that will make it easier for people to help
you.
1) Some sample data  the "f" vector that gets sent into this
function.
2) Comments. All good code should have comments. Yours has virtually
none.
3) Version of MATLAB you are using along with what toolboxes. For
example, do you have the Image Processing Toolbox, which has a bwdist
function? The bwdist function does the Euclidean Distance Transform,
along with some other distance transforms such as city block,
chessboard, and quasieuclidean.
4) Plus I don't even know what "one dimensional squared euclidean
distance transform" or the "quadratic model euclidean distance
transform" is or the difference between them. All I know is the
regular EDT like you'd intuitively think about  you know, the one
that uses the Pythagorean Theorem (BTW, why did Euclid get the eponym
instead of Pythagoras).
5) Not sure what f is. Is it an array of 2D coordinates, like an Nx2
array of (x,y) coordinates? If so, what is "f(p)"? And what does 2p,
p2, and q2 mean? What are those? Are they indexes, or (x,y)
coordinate pairs?
6) A description of the "mistakes" you believe you've made. Do you
have any error messages that were generated, or some output data that
you think is counterintuitive?
Do you have any images that illustrate your problem/mistake/situation
that you can upload to http://drop.io?
