"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
