Hi,
I'm sad to see all the unhelpful comments above when it is really Mathwork's poor implementation leading to this error. The solution is to simply include result = null in your for loop:
for (int j = 1; j < 8; j++)
{
object result1 = null;
string name = path + j + ".JPG";
matlab.Feval("WBC_SegProposed", 6, out result1, name, 0, j);
...........
}
your code works for the first iteration because "result" is set to null by default. Then it gets assigned a value in the first iteration and Feval throws an error due to passing a non-null variable in the second iteration.