Fit a transfer function to gain and phase data

I have the gain and phase data for which I want to find a transfer function. None of the results that I get using "invfreqs" really matches the actual bode plot of the data. Any ideas? I also get the warning: Matrix is close to singular or badly scaled. Results may be inaccurate. RCOND = 4.362258e-030. Thanks!

Reply to
Roza.Mahmoodian
Loading thread data ...

If you're using MatLab it's a good idea to say so. I _assume_ that's where the 'invfreqs' comes from.

The warning sounds like what you'd get if you've asked for too high an order of transfer function -- there's probably a linear matrix problem embedded in there that needs sufficient data to get a good answer.

Having said all that -- I'm not a big advocate of extracting a transfer function from measured data, particularly gain and phase data. The sensible thing to to with extracted transfer functions is to do some sort of pole-placement design -- and this is is really only useful and safe if you're being ultra conservative or if you already have solid domain knowledge.

Unless you're going to use some robust design technique with your extracted transfer function, and that technique requires things in polynomial form, I would suggest that you just use the measured data directly to do your design the old fashioned way using Bode and Nyquist plots. Assuming your measurements are good this leaves little to chance, and gives you a good probability of getting a safe effective controller tuning, or at least an understanding of why you _can't_ get a good safe effective controller tuning.

Reply to
Tim Wescott

Don't forget that there are actually two functions; invfreqs for continuous time data and invfreqz for discrete time data. Make sure you are using the correct one. Also, make sure that you have points over a wide enough frequency range. Check that you have the correct relative degree of the transfer function or the algorithm will complain in the way you describe.

fred.

Reply to
Fred Stevens

The example program for Scilab's frfit function would be a good place to start.

w=0.01:0.01:2;s=poly(0,'s'); G=syslin('c',2*(s^2+0.1*s+2), (s^2+s+1)*(s^2+0.3*s+1)); fresp=repfreq(G,w); Gid=frfit(w,fresp,4); frespfit=repfreq(Gid,w); bode(w,[fresp;frespfit])

The above was copied out of the Scilab documentation. It generates the data which is in a complex form. The OP would have to convert the magnitude and phase to complex numbers but then the rest looks so easy. The Gid is the identified tranfer function. The last two lines just print out the source transfer function and the resulting 'ID' for comparison.

Peter Nachtwey

Reply to
Peter Nachtwey

"Peter Nachtwey" schrieb im Newsbeitrag news: snipped-for-privacy@m73g2000cwd.googlegroups.com...

How do you find the coefficients C and D of the system to be controlled?

e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0)

Reply to
Jan C. Hoffmann

I have know idea what | e.g. (C2*s^2+C1*s+C0)*(D2*s^2+D1*s+D0) is supposed to be. I don't know what you are asking for. Gid is the resulting transfer function

-->Gid Gid = 2 2.8143084 + 0.1316710s + 1.9930258s --------------------------------------------------- 2 3 4 0.7009256 + 1.1251421s + 1.8071075s + 1.2745791s + s

Peter Nachwey

Reply to
Peter Nachtwey

"Peter Nachtwey" schrieb im Newsbeitrag news:3oOdnfDxmcYJ0yvZnZ2dnUVZ snipped-for-privacy@comcast.com...

Sorry for being unprecise in asking.

Let's assume you have an existing system in a power plant. You apply a step function to get information about the system to be controlled.

What is the approach to find the coeffients Ci of e.g. C3*s^3+C2*s^2+C1*s+C0=0, if degree 3 is (for some reason) applicable?

Thanks for answering.

Reply to
Jan C. Hoffmann

First, C3*s^3+C2*s^2+C1*s+C0=0 is not a transfer function with poles. See

formatting link
how to find a simple FOPDT transfer function.

For more sophisticated systems I use the CO and PV, not the gain and phase. I then start with a simple model. I find the coefficients for that model using a minimization program like what can be found in Mathcad ( Minerr ) or Scilab ( lsqrsolve) . I then try a different model. After I have tried all probable models I choose the one with the best fit. This choice must be tempered by a sanity check. I get much better results than the gain and phase with frfit above.

Note the gain can and probably will be non-linear. It is possible to compute Gp(PV) using these non-linear minimization techniques.

The quickest/cheapest way to is to download Scilab and use the lsqrsolve. Get Modeling and Simulation in Scilab/Scicos

formatting link

Reply to
Peter Nachtwey

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.