modified FK2D.m