Note also that fminbnd uses box constraints, and the analogous thing in NLopt is to just write:
lower_bounds!(opt, lbA1) upper_bounds!(opt, ubA1) However, Jude, I should also point out that "I don't want to read the manual, please just write my code for me" is not the most courteous way to solicit unpaid volunteer help. In general, people are more willing to help when you've put in an effort yourself.