for k = 1:size(lambda)
fun_lambda_value(k) = subs(f,[x1,x2],[x_1(i)+lambda(k,1)*S(1),x_2(i)+lambda(k,1)*S(2)])
end
If lamda is a [1 x N] row vector, "1:size(lambda)" means "1:[1,N]". The colon operator uses the first element only, if an argument is a vector.
You want instead:
for k = 1:numel(lambda)
But in your case fun_lambda_value is not defined at all. Then lambda is empty and
[value, index] = min(fun_lambda_value)
cannot work.
I assume, the code has another bug: If lambda is smaller than in the former iteration, only the first elements are overwritten. I assume you want to set fun_lambda_value to a default value before the loop.