How do I constrain a vector's value within a nonlinear fit?

I am fitting a set of data using nlinfit as magnetic dipoles and I want my fitted parameters to be only positive.
How do I make this constraint?

 Accepted Answer

Put them in the fittype equation as parameters-squared.
Best wishes
Torsten.

3 Comments

Could you please explain further, square the parameters then sqrt?
Yes, put the parameters squared in the fittype function and square the results after solving.
Best wishes
Torsten.

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!