How to minimise a function with three input arguments in least squared sense in MATLAB ?

1 view (last 30 days)
I was having a look at the x = lsqnonlin(fun,x0,lb,ub) command in Matlab. But as the syntax shows, the function 'fun' has only one variable 'x' whose initial value is x0 and optimised lb < x < ub. But what If I have a function with three input variables. All the three variables have upper and lower limits respectively. And my objective is to minimise the function with optimal values of these three variables within the specified range. Eg: t = function(x,y,z) I would like to find optimal values of x,y, and z such that value of t is minimised.

Answers (1)

Torsten
Torsten on 20 Mar 2015
x0, lb and ub are not necessarily scalars, but can also be vectors of length 3 ...
Best wishes
Torsten.
  2 Comments
quicklearner
quicklearner on 23 Mar 2015
Thanks a lot for the clarity. But My problem is slightly different. I have a symbolic function in place of the function 'fun' in the lsqnonlin syntax. As per the example provided. it says " * Because lsqnonlin assumes that the sum of squares is not explicitly formed in the user-defined function, the function passed to lsqnonlin should instead compute the vector-valued function * " which means the output of the function should be a vector with n components. But in my case I have a symbolic function whose size is 1 by 1 .
Torsten
Torsten on 24 Mar 2015
Then pass a new function to lsqnonlin in which you call your symbolic function n times to compute the vector (f1,f2,...,fn).
Best wishes
Torsten.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!