italic I am not able understand this behavior.
Nor can we w/o seeing what you did...
I don't know Simulink at all, but is there not an interpolation/lookup block you could use directly w/o an explicit FOR...END loop?
If not, could write s-function and use intersect()
NB you'll need to always have an exact input match--maybe that's the problem in the simulation?