Thread Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Mario Ruz

Date: 16 Jul, 2008 23:20:04

Message: 1 of 13

Hi everybody,

I need to estimate parameters of a defined structure of a
transfer function. Suppose for example the transfer
function K/(s+a).
Given frequency data (module, phase and frequency for each
point given) I need to minimize the next function cost:

F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N =number
of frequency data given)

Ci and Di are the real and imaginary part of the data given
(N points given at certain frequencies), which are known.
Xi and Yi are the real and imaginary part of the transfer
function estimated (which depends in this case of the
parameters K and a) at the "i" point frequency (in rad/s).

So, Xi and Yi depends on the parameters and the point
frequency. For example, at the frequency "w"--> s=j*w, we
have K/(j*w+a), and here we could obtaint the real and
imaginary part.

How can I minimize this function cost and which
optimization function should I use? There parameters (K and
a in the eample) which would minimize the function cost are
the variables unknown.

Subject: Function cost optimization. Transfer function estimation,

From: vedenev

Date: 17 Jul, 2008 04:42:12

Message: 2 of 13

fminsearch - search minimum of function
quadprog - minimize quadratic function with constrains (in
Optimization Toolbox)

------------------------------------
Maxim Vedenev, Matlab freelancer
http://simulations.narod.ru/

Subject: Function cost optimization. Transfer function estimation,

From: Mario Ruz

Date: 17 Jul, 2008 05:32:35

Message: 3 of 13

vedenev <vedenev.maxim@gmail.com> wrote in message
<a397900d-425c-41cf-9c6c-
92dbb5a4dfc9@z72g2000hsb.googlegroups.com>...
> fminsearch - search minimum of function
> quadprog - minimize quadratic function with constrains
(in
> Optimization Toolbox)
>
> ------------------------------------
> Maxim Vedenev, Matlab freelancer
> http://simulations.narod.ru/

Hi Vedenev,

Quadprog, as you said, minimize a quadratic function. My
function cost is a sum of two squares, so it is not useful.

As for fminsearch, it minimizes a function, but not a sum
as i want. I do not know if i can develop a sum inside the
function objetive to pass it.Anyway I forget to say that
the parameters ARE BOUNDED (with a maximum and a minimum),
so it is neither useful.

Subject: Function cost optimization. Transfer function estimation,

From: Rune Allnor

Date: 17 Jul, 2008 11:49:31

Message: 4 of 13

On 17 Jul, 01:20, "Mario Ruz" <mario_...@hotmail.com> wrote:
> Hi everybody,
>
> I need to estimate parameters of a defined structure of a
> transfer function. Suppose for example the transfer
> function K/(s+a).
> Given frequency data (module, phase and frequency for each
> point given) I need to minimize the next function cost:
>
> F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N =number
> of frequency data given)

This type of problem was addressed by Ken Steiglitz in the
early '70s. Check out his papers in IEEE Trans actions on
Acoustics, Speech and Signal Processing.

Rune

Subject: Function cost optimization. Transfer function estimation,

From: Mario Ruz

Date: 17 Jul, 2008 16:10:19

Message: 5 of 13

Rune Allnor <allnor@tele.ntnu.no> wrote in message
<0124be61-7dca-4782-89fe-
8f39b00169c8@i76g2000hsf.googlegroups.com>...
> On 17 Jul, 01:20, "Mario Ruz" <mario_...@hotmail.com>
wrote:
> > Hi everybody,
> >
> > I need to estimate parameters of a defined structure of
a
> > transfer function. Suppose for example the transfer
> > function K/(s+a).
> > Given frequency data (module, phase and frequency for
each
> > point given) I need to minimize the next function cost:
> >
> > F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
=number
> > of frequency data given)
>
> This type of problem was addressed by Ken Steiglitz in the
> early '70s. Check out his papers in IEEE Trans actions on
> Acoustics, Speech and Signal Processing.
>
> Rune

The key for me is how to implement the cost function i
posted in the first post. I don?t know which is the
function of optim toolbox that I should use.

Kind regards, Mario

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Rakesh Kumar

Date: 18 Jul, 2008 13:32:01

Message: 6 of 13

"Mario Ruz" <mario_ruz@hotmail.com> wrote in message
<g5lvn4$b11$1@fred.mathworks.com>...
> Hi everybody,
>
> I need to estimate parameters of a defined structure of a
> transfer function. Suppose for example the transfer
> function K/(s+a).
> Given frequency data (module, phase and frequency for each
> point given) I need to minimize the next function cost:
>
> F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N =number
> of frequency data given)
>
> Ci and Di are the real and imaginary part of the data given
> (N points given at certain frequencies), which are known.
> Xi and Yi are the real and imaginary part of the transfer
> function estimated (which depends in this case of the
> parameters K and a) at the "i" point frequency (in rad/s).
>
> So, Xi and Yi depends on the parameters and the point
> frequency. For example, at the frequency "w"--> s=j*w, we
> have K/(j*w+a), and here we could obtaint the real and
> imaginary part.
>
> How can I minimize this function cost and which
> optimization function should I use? There parameters (K and
> a in the eample) which would minimize the function cost are
> the variables unknown.

You can try lsqnonlin function. Here is a section from the
help for this function.
>>help lsqnonlin
LSQNONLIN solves non-linear least squares problems.
LSQNONLIN attempts to solve problems of the form:
min sum {FUN(X).^2} where X and the values returned by FUN
can be vectors or matrices.

Your objective should return the vector (not the sum) to the
solver.

An alternative is to use lsqcurvefit function that can also
solve your problem in an easier way. You can provide your
data (C,D) to the solver as well.

LSQCURVEFIT solves non-linear least squares problems.
LSQCURVEFIT attempts to solve problems of the form:
min sum {(FUN(X,XDATA)-YDATA).^2} where X, XDATA, YDATA
and the values returned by FUN can be vectors or matrices.

Rakesh

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Mario Ruz

Date: 18 Jul, 2008 14:19:03

Message: 7 of 13

"Rakesh Kumar" <r.kumar_spamhole@mathworks.com> wrote in
message <g5q60h$j79$1@fred.mathworks.com>...
> "Mario Ruz" <mario_ruz@hotmail.com> wrote in message
> <g5lvn4$b11$1@fred.mathworks.com>...
> > Hi everybody,
> >
> > I need to estimate parameters of a defined structure of
a
> > transfer function. Suppose for example the transfer
> > function K/(s+a).
> > Given frequency data (module, phase and frequency for
each
> > point given) I need to minimize the next function cost:
> >
> > F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
=number
> > of frequency data given)
> >
> > Ci and Di are the real and imaginary part of the data
given
> > (N points given at certain frequencies), which are
known.
> > Xi and Yi are the real and imaginary part of the
transfer
> > function estimated (which depends in this case of the
> > parameters K and a) at the "i" point frequency (in
rad/s).
> >
> > So, Xi and Yi depends on the parameters and the point
> > frequency. For example, at the frequency "w"--> s=j*w,
we
> > have K/(j*w+a), and here we could obtaint the real and
> > imaginary part.
> >
> > How can I minimize this function cost and which
> > optimization function should I use? There parameters (K
and
> > a in the eample) which would minimize the function cost
are
> > the variables unknown.
>
> You can try lsqnonlin function. Here is a section from the
> help for this function.
> >>help lsqnonlin
> LSQNONLIN solves non-linear least squares problems.
> LSQNONLIN attempts to solve problems of the form:
> min sum {FUN(X).^2} where X and the values returned by
FUN
> can be vectors or matrices.
>
> Your objective should return the vector (not the sum) to
the
> solver.
>
> An alternative is to use lsqcurvefit function that can
also
> solve your problem in an easier way. You can provide your
> data (C,D) to the solver as well.
>
> LSQCURVEFIT solves non-linear least squares problems.
> LSQCURVEFIT attempts to solve problems of the form:
> min sum {(FUN(X,XDATA)-YDATA).^2} where X, XDATA, YDATA
> and the values returned by FUN can be vectors or matrices.
>
> Rakesh

Thank you very much Rakesh. The main problem is that my
function, as you can see, is not the form "min sum {FUN
(X).^2}", but "min sum {FUN(X)}" where F(X) is [(Xi-Ci)^2+
(Yi-Di)^2]. I tried with fmincon, but I did the sum inside
the objective function, and I am not sure if it is done
correctly. Anyway, I think the choice you tell is one
solution for my problem.

I will try to solve this, If I achieve a solution i will
let you know.

Kind regards, Mario.

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Mario Ruz

Date: 18 Jul, 2008 14:35:03

Message: 8 of 13

In fact I think it is possible because min sum[(Xi-Ci)^2+
(Yi-Di)^2] is equal to min sum{[(Xi-Ci)^2+(Yi-Di)^2]^2},
because in both cases we have to minimize [(Xi-Ci)^2+(Yi-Di)
^2].

The last case is a function which can be implemented with
lsqnonlin.

So...We?ll see...

Kind regards, Mario

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Rajiv Singh

Date: 23 Jul, 2008 21:51:37

Message: 9 of 13

Hi Mario,
For fitting frequency data to linear models, such as linear transfer
functions, you may use the functions in system identification toolbox. Look
at estimation functions such as arx, armax, oe and pem. Low order transfer
functions in continuous time may be directly estimated using IDPROC models.

Rajiv


"Mario Ruz" <mario_ruz@hotmail.com> wrote in message
news:g5lvn4$b11$1@fred.mathworks.com...
> Hi everybody,
>
> I need to estimate parameters of a defined structure of a
> transfer function. Suppose for example the transfer
> function K/(s+a).
> Given frequency data (module, phase and frequency for each
> point given) I need to minimize the next function cost:
>
> F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N =number
> of frequency data given)
>
> Ci and Di are the real and imaginary part of the data given
> (N points given at certain frequencies), which are known.
> Xi and Yi are the real and imaginary part of the transfer
> function estimated (which depends in this case of the
> parameters K and a) at the "i" point frequency (in rad/s).
>
> So, Xi and Yi depends on the parameters and the point
> frequency. For example, at the frequency "w"--> s=j*w, we
> have K/(j*w+a), and here we could obtaint the real and
> imaginary part.
>
> How can I minimize this function cost and which
> optimization function should I use? There parameters (K and
> a in the eample) which would minimize the function cost are
> the variables unknown.

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Matt

Date: 23 Jul, 2008 22:53:02

Message: 10 of 13

"Mario Ruz" <mario_ruz@hotmail.com> wrote in message <g5lvn4
$b11$1@fred.mathworks.com>...
> Hi everybody,
>
> I need to estimate parameters of a defined structure of a
> transfer function. Suppose for example the transfer
> function K/(s+a).
> Given frequency data (module, phase and frequency for
each
> point given) I need to minimize the next function cost:
>
> F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
=number
> of frequency data given)
>
> Ci and Di are the real and imaginary part of the data
given
> (N points given at certain frequencies), which are known.
> Xi and Yi are the real and imaginary part of the transfer
> function estimated (which depends in this case of the
> parameters K and a) at the "i" point frequency (in rad/s).

Hi Mario,

If you reformulate your cost function, you can turn this
into a simple quadratic minimization problem and avoid all
need for complicated MATLAB minimization functions.

In particular, you have currently defined a cost function
which looks at the difference between K/(s+a) and your
transfer function data C(s)+i*D(s). Instead, however, you
can minimize the squared difference

 F2(K,a) = ( K-(s+a)*(C(s)+i*D(s)) )^2

Note that this function will also get smaller and smaller
the more K/(s+a) agrees with the data. However, F2()
is a simple quadratic function in K and a. You can minimize
it by solving a linear equation. Basic MATLAB tools for
Gaussian elimination should do the job.

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Mario Ruz

Date: 28 Jul, 2008 15:18:02

Message: 11 of 13

Hi Matt and everybody. I definetly solved my problem,
passing parameters in form of vectors with my function cost
has been factible. In the case of lsqnonlin solver, the
minimum produced by min {sum f(x)^2} is the same that min
{sum f(x)^2}, knowing also that f(x) >0 always (see my
first post for knowing more about the cost function).

If someone need the .m code I can pass it. I could obtain
almost a 100% fit given a Bode curve starting from
frequency data given, I estimated a model in the S domain
(transfer function) which follows that Bode curve (phase
and module).

So the problem is solved. One improvement would be making
dynamic the structure in the cost function (number of
poles, zeros..., as parameters).

Kind regards, Mario.




"Matt " <mjacobson.removethis@xorantech.com> wrote in
message <g68coe$c0h$1@fred.mathworks.com>...
> "Mario Ruz" <mario_ruz@hotmail.com> wrote in message
<g5lvn4
> $b11$1@fred.mathworks.com>...
> > Hi everybody,
> >
> > I need to estimate parameters of a defined structure of
a
> > transfer function. Suppose for example the transfer
> > function K/(s+a).
> > Given frequency data (module, phase and frequency for
> each
> > point given) I need to minimize the next function cost:
> >
> > F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
> =number
> > of frequency data given)
> >
> > Ci and Di are the real and imaginary part of the data
> given
> > (N points given at certain frequencies), which are
known.
> > Xi and Yi are the real and imaginary part of the
transfer
> > function estimated (which depends in this case of the
> > parameters K and a) at the "i" point frequency (in
rad/s).
>
> Hi Mario,
>
> If you reformulate your cost function, you can turn this
> into a simple quadratic minimization problem and avoid
all
> need for complicated MATLAB minimization functions.
>
> In particular, you have currently defined a cost function
> which looks at the difference between K/(s+a) and your
> transfer function data C(s)+i*D(s). Instead, however, you
> can minimize the squared difference
>
> F2(K,a) = ( K-(s+a)*(C(s)+i*D(s)) )^2
>
> Note that this function will also get smaller and smaller
> the more K/(s+a) agrees with the data. However, F2()
> is a simple quadratic function in K and a. You can
minimize
> it by solving a linear equation. Basic MATLAB tools for
> Gaussian elimination should do the job.
>
>
>
>
>
>

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: Teresa Mendoza

Date: 21 Oct, 2010 17:09:04

Message: 12 of 13

Hi Mario
I'm trying a similar problem for identification of parameters of a transfer function and wanted to solve by the method of Levenberg Marquardt that according to the IEEE 115 standard fit for my problem, a favor cooperation could spend your code would be very grateful

Teresa

"Mario Ruz" <mario_ruz@hotmail.com> wrote in message <g6knva$mth$1@fred.mathworks.com>...
> Hi Matt and everybody. I definetly solved my problem,
> passing parameters in form of vectors with my function cost
> has been factible. In the case of lsqnonlin solver, the
> minimum produced by min {sum f(x)^2} is the same that min
> {sum f(x)^2}, knowing also that f(x) >0 always (see my
> first post for knowing more about the cost function).
>
> If someone need the .m code I can pass it. I could obtain
> almost a 100% fit given a Bode curve starting from
> frequency data given, I estimated a model in the S domain
> (transfer function) which follows that Bode curve (phase
> and module).
>
> So the problem is solved. One improvement would be making
> dynamic the structure in the cost function (number of
> poles, zeros..., as parameters).
>
> Kind regards, Mario.
>
>
>
>
> "Matt " <mjacobson.removethis@xorantech.com> wrote in
> message <g68coe$c0h$1@fred.mathworks.com>...
> > "Mario Ruz" <mario_ruz@hotmail.com> wrote in message
> <g5lvn4
> > $b11$1@fred.mathworks.com>...
> > > Hi everybody,
> > >
> > > I need to estimate parameters of a defined structure of
> a
> > > transfer function. Suppose for example the transfer
> > > function K/(s+a).
> > > Given frequency data (module, phase and frequency for
> > each
> > > point given) I need to minimize the next function cost:
> > >
> > > F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
> > =number
> > > of frequency data given)
> > >
> > > Ci and Di are the real and imaginary part of the data
> > given
> > > (N points given at certain frequencies), which are
> known.
> > > Xi and Yi are the real and imaginary part of the
> transfer
> > > function estimated (which depends in this case of the
> > > parameters K and a) at the "i" point frequency (in
> rad/s).
> >
> > Hi Mario,
> >
> > If you reformulate your cost function, you can turn this
> > into a simple quadratic minimization problem and avoid
> all
> > need for complicated MATLAB minimization functions.
> >
> > In particular, you have currently defined a cost function
> > which looks at the difference between K/(s+a) and your
> > transfer function data C(s)+i*D(s). Instead, however, you
> > can minimize the squared difference
> >
> > F2(K,a) = ( K-(s+a)*(C(s)+i*D(s)) )^2
> >
> > Note that this function will also get smaller and smaller
> > the more K/(s+a) agrees with the data. However, F2()
> > is a simple quadratic function in K and a. You can
> minimize
> > it by solving a linear equation. Basic MATLAB tools for
> > Gaussian elimination should do the job.
> >
> >
> >
> >
> >
> >
>

Subject: Function cost optimization. Transfer function estimation, starting from frequency data given.

From: MRR

Date: 22 Oct, 2010 13:30:24

Message: 13 of 13

Hi Teresa,

Unfortunately I am out of my office and I do not have the .m files here. I took a look to Levenberg Marquardt and it seems a quite similar problem to the one here stated.

The only thing I can say you is that the problem can be solved, sorry.

Mario


"Teresa Mendoza" <terhemaz@gmail.com> wrote in message <i9ps3g$25n$1@fred.mathworks.com>...
> Hi Mario
> I'm trying a similar problem for identification of parameters of a transfer function and wanted to solve by the method of Levenberg Marquardt that according to the IEEE 115 standard fit for my problem, a favor cooperation could spend your code would be very grateful
>
> Teresa
>
> "Mario Ruz" <mario_ruz@hotmail.com> wrote in message <g6knva$mth$1@fred.mathworks.com>...
> > Hi Matt and everybody. I definetly solved my problem,
> > passing parameters in form of vectors with my function cost
> > has been factible. In the case of lsqnonlin solver, the
> > minimum produced by min {sum f(x)^2} is the same that min
> > {sum f(x)^2}, knowing also that f(x) >0 always (see my
> > first post for knowing more about the cost function).
> >
> > If someone need the .m code I can pass it. I could obtain
> > almost a 100% fit given a Bode curve starting from
> > frequency data given, I estimated a model in the S domain
> > (transfer function) which follows that Bode curve (phase
> > and module).
> >
> > So the problem is solved. One improvement would be making
> > dynamic the structure in the cost function (number of
> > poles, zeros..., as parameters).
> >
> > Kind regards, Mario.
> >
> >
> >
> >
> > "Matt " <mjacobson.removethis@xorantech.com> wrote in
> > message <g68coe$c0h$1@fred.mathworks.com>...
> > > "Mario Ruz" <mario_ruz@hotmail.com> wrote in message
> > <g5lvn4
> > > $b11$1@fred.mathworks.com>...
> > > > Hi everybody,
> > > >
> > > > I need to estimate parameters of a defined structure of
> > a
> > > > transfer function. Suppose for example the transfer
> > > > function K/(s+a).
> > > > Given frequency data (module, phase and frequency for
> > > each
> > > > point given) I need to minimize the next function cost:
> > > >
> > > > F(parameters)= sum[(Xi-Ci)^2+(Yi-Di)^2]; i=1...N (N
> > > =number
> > > > of frequency data given)
> > > >
> > > > Ci and Di are the real and imaginary part of the data
> > > given
> > > > (N points given at certain frequencies), which are
> > known.
> > > > Xi and Yi are the real and imaginary part of the
> > transfer
> > > > function estimated (which depends in this case of the
> > > > parameters K and a) at the "i" point frequency (in
> > rad/s).
> > >
> > > Hi Mario,
> > >
> > > If you reformulate your cost function, you can turn this
> > > into a simple quadratic minimization problem and avoid
> > all
> > > need for complicated MATLAB minimization functions.
> > >
> > > In particular, you have currently defined a cost function
> > > which looks at the difference between K/(s+a) and your
> > > transfer function data C(s)+i*D(s). Instead, however, you
> > > can minimize the squared difference
> > >
> > > F2(K,a) = ( K-(s+a)*(C(s)+i*D(s)) )^2
> > >
> > > Note that this function will also get smaller and smaller
> > > the more K/(s+a) agrees with the data. However, F2()
> > > is a simple quadratic function in K and a. You can
> > minimize
> > > it by solving a linear equation. Basic MATLAB tools for
> > > Gaussian elimination should do the job.
> > >
> > >
> > >
> > >
> > >
> > >
> >

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

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.

rssFeed for this Thread

Contact us at files@mathworks.com