Lets start by reading the error message: "Supplied objective function must return a scalar value"
So, the objective function must return a scalar value. A scalr has size 1x1. Lets run the objective function and see if it returns a scalar value:
>> X = Trans_eqn_taperedfiber([1/3,2/3]);
>> size(X)
ans =
1 49000
Is 1x49000 scalar? No. So the problem is your function returns a vector, which both the documentation and the error message clearly state is not allowed. You need to change your function to return a scalar value. Also note that you could generate a, b, and c without the loop using simpler vectorized code.
Best Answer