Got Questions? Get Answers.
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Optimization: lsqnonlin

Subject: Optimization: lsqnonlin

From: Kai

Date: 3 Feb, 2009 12:31:23

Message: 1 of 2

Hello,

I'd like to optimize some parameters x that describe a kinematic model. For
this I'm using Optimization Toolbox with Matlab.

I have 10 sets of measurement data describing a position P. Now I want to
optimize my parameters x, so that

P = f(x) or for matlab 0 = f(x) - P

What is the best (in terms of numerically successful) way to do this? At the
moment, I create an array of functions f1..f10 in my optimization function
f to use all the measurment data. So my optimization function becomes:

0 = f(x1) - P1
0 = f(x2) - P2
...
0 = f(x10) - P10

=

0 = f_all(x) - P_all

I think it's not the best way. How can I use different measurment data
points for a optimization function in the way I described it?

Subject: Optimization: lsqnonlin

From: Miroslav Balda

Date: 3 Feb, 2009 22:11:01

Message: 2 of 2

Kai <invalid@invalid.invalid> wrote in message <6uqrorFgjn0rU1@mid.dfncis.de>...
> Hello,
>
> I'd like to optimize some parameters x that describe a kinematic model. For
> this I'm using Optimization Toolbox with Matlab.
>
> I have 10 sets of measurement data describing a position P. Now I want to
> optimize my parameters x, so that
>
> P = f(x) or for matlab 0 = f(x) - P
>
> What is the best (in terms of numerically successful) way to do this? At the
> moment, I create an array of functions f1..f10 in my optimization function
> f to use all the measurment data. So my optimization function becomes:
>
> 0 = f(x1) - P1
> 0 = f(x2) - P2
> ...
> 0 = f(x10) - P10
>
> =
>
> 0 = f_all(x) - P_all
>
> I think it's not the best way. How can I use different measurment data
> points for a optimization function in the way I described it?

Hi
I do not understand your question well. Perhaps, it is the reason why nobody answered it yet.
I guess that you have a problem:
   f(x,c) = y, where
x is a vector of independent variables,
y is a vector of dependent function values,
c is a vector of unknown parameters and f() is a (non)linear function of x.
If it is your problem to solve, you have to create a function, say 'resid.m', which will evaluate residuals of the above written equation:

function res =resid(c)
global x y
res = "f(x,c)" - y; % where "f(x,c)" should be replaced by a code for your function

Global variables x and y might be transfered to the function also by another way (see documentation).
Having no Optimization Toolbox, I would use my function LMFnlsq (FEX Id 17534):

[c,ssq,cnt] = LMFnlsq('resid',c0)

c0 is your guess of possible solution of unknown coefficients c.
Should your function be linear in c, the solution would be much easier via pseudoinverse or by '\' operator.

Hope it helps.

Mira

Tags for this Thread

No tags are associated with this thread.

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us