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!
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.
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.
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.
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
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
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.