First, do not use eval. It's not the cause for your problem here but it's a very dangerous tool which typically makes it harder to debug your code. It's also completely unneeded here,
would work just as well.
As for the error, we don't have enough information to say what the problem is exactly, most likely the size of m_test(start_idx:end_idx) is not the same as the size of 10^(M.VAR/20)*y2 and the most likely reason for that is that y2 doesn't have end_idx-start_idx+1 elements or if it has, is not a vector. Since we don't know the size of the variables, their shape, or where they come from, we can't help you further.