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:
transfer fcn fitting: invfreqs

Subject: transfer fcn fitting: invfreqs

From: pietro

Date: 17 Jan, 2011 14:28:05

Message: 1 of 7

Hi,

I need to fit a transfer function from measured data. The transfer function must be in this form:

http://img691.imageshack.us/f/fdtsimb.jpg/

How can I set up the coefficient constraints?

Thanks

Pietro

Subject: transfer fcn fitting: invfreqs

From: Miroslav Balda

Date: 17 Jan, 2011 21:00:21

Message: 2 of 7

"pietro " <bracardi82@email.it> wrote in message <ih1jlk$vj$1@fred.mathworks.com>...
> Hi,
>
> I need to fit a transfer function from measured data. The transfer function must be in this form:
>
> http://img691.imageshack.us/f/fdtsimb.jpg/
>
> How can I set up the coefficient constraints?
>
> Thanks
>
> Pietro

Hi Pietro,

Maybe that the following steps could solve your problem
1. Linearize your formula F(s) = top(a,b,c,s)/bot(d,e,,b,c,s) by multiplication of both sides by bot(...).
2. Use linear regression to obtain 1st approximation of a,b,c,d,e.
3. Apply any nonlinear solver to the original formula for F(s) with coefficiets from the step 2 for finding real estimates of a,b,c,d,e, which best approximate your measured F(s).
This procedure may converge in case, when measurement errors be small. Otherwise, the iteration process may diverge. One possible way to stabilize it is in application of the function aitkd2 from FEX:
     www.mathworks.com/matlabcentral/fileexchange/11584
Hope it helps.

Mira

Subject: transfer fcn fitting: invfreqs

From: pietro

Date: 18 Jan, 2011 08:44:05

Message: 3 of 7

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ih2al5$qmk$1@fred.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <ih1jlk$vj$1@fred.mathworks.com>...
> > Hi,
> >
> > I need to fit a transfer function from measured data. The transfer function must be in this form:
> >
> > http://img691.imageshack.us/f/fdtsimb.jpg/
> >
> > How can I set up the coefficient constraints?
> >
> > Thanks
> >
> > Pietro
>
> Hi Pietro,
>
> Maybe that the following steps could solve your problem
> 1. Linearize your formula F(s) = top(a,b,c,s)/bot(d,e,,b,c,s) by multiplication of both sides by bot(...).
> 2. Use linear regression to obtain 1st approximation of a,b,c,d,e.
> 3. Apply any nonlinear solver to the original formula for F(s) with coefficiets from the step 2 for finding real estimates of a,b,c,d,e, which best approximate your measured F(s).
> This procedure may converge in case, when measurement errors be small. Otherwise, the iteration process may diverge. One possible way to stabilize it is in application of the function aitkd2 from FEX:
> www.mathworks.com/matlabcentral/fileexchange/11584
> Hope it helps.
>
> Mira

Hi Miro,

thanks for your suggestion, may you explaint to me in detail how I can do this? In particular I don't understand how to perform the first two steps:
1- Is F(s) the complex array of measured transfer function?
2- How can I linearize the formula with matlab?
3- Which function can I use for regression analysis with complex data?

Thanks again

Pietro

Subject: transfer fcn fitting: invfreqs

From: Miroslav Balda

Date: 18 Jan, 2011 21:49:04

Message: 4 of 7

"pietro " <bracardi82@email.it> wrote in message <ih3jsl$g5g$1@fred.mathworks.com>...
> "Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ih2al5$qmk$1@fred.mathworks.com>...
> > "pietro " <bracardi82@email.it> wrote in message <ih1jlk$vj$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I need to fit a transfer function from measured data. The transfer function must be in this form:
> > >
> > > http://img691.imageshack.us/f/fdtsimb.jpg/
> > >
> > > How can I set up the coefficient constraints?
> > >
> > > Thanks
> > >
> > > Pietro
> >
> > Hi Pietro,
> >
> > Maybe that the following steps could solve your problem
> > 1. Linearize your formula F(s) = top(a,b,c,s)/bot(d,e,,b,c,s) by multiplication of both sides by bot(...).
> > 2. Use linear regression to obtain 1st approximation of a,b,c,d,e.
> > 3. Apply any nonlinear solver to the original formula for F(s) with coefficiets from the step 2 for finding real estimates of a,b,c,d,e, which best approximate your measured F(s).
> > This procedure may converge in case, when measurement errors be small. Otherwise, the iteration process may diverge. One possible way to stabilize it is in application of the function aitkd2 from FEX:
> > www.mathworks.com/matlabcentral/fileexchange/11584
> > Hope it helps.
> >
> > Mira
>
> Hi Miro,
>
> thanks for your suggestion, may you explaint to me in detail how I can do this? In particular I don't understand how to perform the first two steps:
> 1- Is F(s) the complex array of measured transfer function?
> 2- How can I linearize the formula with matlab?
> 3- Which function can I use for regression analysis with complex data?
>
> Thanks again
>
> Pietro

Hi Pietro,

Let us hope that you know measured F(f), where f is the real frequency. It means that you will work with complex frequency responses F(f).
1. In the first step, you get
     bot(d,e,b,c, f)*F(f) - top(a,b, f) = 0 ..................... (1)
what is a linear equation for [a;b;c;d;e]. For length(f)>5, it builds an overdetermined system of complex linear algebraic equations
     A(f)*[a;b;c;d;e] = B(f), f_min <= f <= f_max ...... (2)
with the solution
     x0 = A(f) \ B(f), where x0=[a;b;c;d;e];
Since you would get complex [a;b;c;d;e], if A(f) and B(f) be complex, you have to build the matrix A(f) and vector B(f) out of real and imaginary parts of eqn (1).
As soon as this is solved you enter into a function, say driver.m with F = F(f).

2. function [x,ssq,cnt,p] = driver(F,f,x0)
     Set x0 = [a;b;c;d;e];
     [x,ssq,cnt] = LMFnlsq('resid',ones(5,1), 'Display',-50, 'MaxIter',1000)
      p = x.*p0;
The function for solving overdetermined system of nonlinear algebraic equations can be found in FEX at
      www.mathworks.com/matlabcentral/fileexchange/17534
A description of the function LMFnlsq is also there.
The first agument 'resid' is the name of the function that evaluates a vector of real residuals of the system of nonlinear equations split in real and imaginary parts. Th function resid is nested function in driver.m., otherwise you woud need to tranfer data into it by global variables.

function r = resid(x)
     p = x,*p0;
     Fp = F(p,f) % evaluate the formula for the frequency response
     r = [real(F(p,f))-imag(F(p,f)-real(F(f)); imag(F(p,f))+real(F(p,f))-imag(F(f))] ;
end

F(p,f) is a vector which elements are top(p,f)/bot(p,f), and
F(f) is vector of measured frequency responses.

I hope that I have explained it under your wishes. Good luck!

Mira

Subject: transfer fcn fitting: invfreqs

From: pietro

Date: 19 Jan, 2011 09:17:05

Message: 5 of 7

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ih51sg$8pv$1@fred.mathworks.com>...
> "pietro " <bracardi82@email.it> wrote in message <ih3jsl$g5g$1@fred.mathworks.com>...
> > "Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ih2al5$qmk$1@fred.mathworks.com>...
> > > "pietro " <bracardi82@email.it> wrote in message <ih1jlk$vj$1@fred.mathworks.com>...
> > > > Hi,
> > > >
> > > > I need to fit a transfer function from measured data. The transfer function must be in this form:
> > > >
> > > > http://img691.imageshack.us/f/fdtsimb.jpg/
> > > >
> > > > How can I set up the coefficient constraints?
> > > >
> > > > Thanks
> > > >
> > > > Pietro
> > >
> > > Hi Pietro,
> > >
> > > Maybe that the following steps could solve your problem
> > > 1. Linearize your formula F(s) = top(a,b,c,s)/bot(d,e,,b,c,s) by multiplication of both sides by bot(...).
> > > 2. Use linear regression to obtain 1st approximation of a,b,c,d,e.
> > > 3. Apply any nonlinear solver to the original formula for F(s) with coefficiets from the step 2 for finding real estimates of a,b,c,d,e, which best approximate your measured F(s).
> > > This procedure may converge in case, when measurement errors be small. Otherwise, the iteration process may diverge. One possible way to stabilize it is in application of the function aitkd2 from FEX:
> > > www.mathworks.com/matlabcentral/fileexchange/11584
> > > Hope it helps.
> > >
> > > Mira
> >
> > Hi Miro,
> >
> > thanks for your suggestion, may you explaint to me in detail how I can do this? In particular I don't understand how to perform the first two steps:
> > 1- Is F(s) the complex array of measured transfer function?
> > 2- How can I linearize the formula with matlab?
> > 3- Which function can I use for regression analysis with complex data?
> >
> > Thanks again
> >
> > Pietro
>
> Hi Pietro,
>
> Let us hope that you know measured F(f), where f is the real frequency. It means that you will work with complex frequency responses F(f).
> 1. In the first step, you get
> bot(d,e,b,c, f)*F(f) - top(a,b, f) = 0 ..................... (1)
> what is a linear equation for [a;b;c;d;e]. For length(f)>5, it builds an overdetermined system of complex linear algebraic equations
> A(f)*[a;b;c;d;e] = B(f), f_min <= f <= f_max ...... (2)
> with the solution
> x0 = A(f) \ B(f), where x0=[a;b;c;d;e];
> Since you would get complex [a;b;c;d;e], if A(f) and B(f) be complex, you have to build the matrix A(f) and vector B(f) out of real and imaginary parts of eqn (1).
> As soon as this is solved you enter into a function, say driver.m with F = F(f).
>
> 2. function [x,ssq,cnt,p] = driver(F,f,x0)
> Set x0 = [a;b;c;d;e];
> [x,ssq,cnt] = LMFnlsq('resid',ones(5,1), 'Display',-50, 'MaxIter',1000)
> p = x.*p0;
> The function for solving overdetermined system of nonlinear algebraic equations can be found in FEX at
> www.mathworks.com/matlabcentral/fileexchange/17534
> A description of the function LMFnlsq is also there.
> The first agument 'resid' is the name of the function that evaluates a vector of real residuals of the system of nonlinear equations split in real and imaginary parts. Th function resid is nested function in driver.m., otherwise you woud need to tranfer data into it by global variables.
>
> function r = resid(x)
> p = x,*p0;
> Fp = F(p,f) % evaluate the formula for the frequency response
> r = [real(F(p,f))-imag(F(p,f)-real(F(f)); imag(F(p,f))+real(F(p,f))-imag(F(f))] ;
> end
>
> F(p,f) is a vector which elements are top(p,f)/bot(p,f), and
> F(f) is vector of measured frequency responses.
>
> I hope that I have explained it under your wishes. Good luck!
>
> Mira

Hi Mira,

Thanks a lot for your help, what are the matrix A(f) and the array B(f)?

Thanks again

Pietro

Subject: transfer fcn fitting: invfreqs

From: Miroslav Balda

Date: 19 Jan, 2011 13:50:05

Message: 6 of 7

> Hi Mira,
>
> Thanks a lot for your help, what are the matrix A(f) and the array B(f)?
>
> Thanks again
>
> Pietro

Hi Pietro,
I thought that you are able to multiply a polynomial by a scalar and then gather terms containing the same unknown coefficient (a,b,...) into a matrix A, and an absolute term into a vector B. If not, then it is difficult to give any advise. It would take me less time to set it I myself than to try to explaiin it without a presentation.
    Send me the vectors f and F(f) and I shall show you how to make it as soon as I'll have a free while.
Best regards,
Mira

Subject: transfer fcn fitting: invfreqs

From: pietro

Date: 20 Jan, 2011 09:43:05

Message: 7 of 7

"Miroslav Balda" <miroslav.nospam@balda.cz> wrote in message <ih6q6d$nms$1@fred.mathworks.com>...
> > Hi Mira,
> >
> > Thanks a lot for your help, what are the matrix A(f) and the array B(f)?
> >
> > Thanks again
> >
> > Pietro
>
> Hi Pietro,
> I thought that you are able to multiply a polynomial by a scalar and then gather terms containing the same unknown coefficient (a,b,...) into a matrix A, and an absolute term into a vector B. If not, then it is difficult to give any advise. It would take me less time to set it I myself than to try to explaiin it without a presentation.
> Send me the vectors f and F(f) and I shall show you how to make it as soon as I'll have a free while.
> Best regards,
> Mira

Hi Mira,

My matter is to understand what are A and B. I'm be able to use matlab, but I'm not so good in the mathematical background so I need all the formula derivations. Maybe with the matlab code, it should be much simpler to understand.
This is the link where you can download the complex array function. I hope it will works.

http://www.megaupload.com/?d=LDSACZ0X7

thanks a lot Mira

Best regards

Pietro

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