We cannot know, what YBUS and IP_DATA is. It is your turn to check, if the error message concerns the variable e, g or f. Do this using the debugger. Type this in the command window:
Run your code again. When Matlab stops at the error use size() to check the sizes of the potentially concerned variables.
My guess: After
the expression b(i,k) does not work for i or k > 1.