From: Erik F. <er...@er...> - 2014-03-24 08:29:12
|
Hi Everyone, while designing a controller based on measured frequency response data I noticed some strange results by in control.nyquist_plot(). Looking at the code I noticed that it first calculates the magnitude and the phase of the system response and then converts it back to the x and y components. I have modified control.nyquist_plot() to directly use the complex frequency response for plotting: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Index: src/freqplot.py =================================================================== --- src/freqplot.py (revision 293) +++ src/freqplot.py (working copy) @@ -227,14 +227,12 @@ #TODO: Add MIMO nyquist plots. raise NotImplementedError("Nyquist is currently only implemented for SISO systems.") else: - # Get the magnitude and phase of the system - mag_tmp, phase_tmp, omega = sys.freqresp(omega) - mag = np.squeeze(mag_tmp) - phase = np.squeeze(phase_tmp) + # Get the system response as complex numbers + z = sys.evalfr(omega)[0,0,:] # Compute the primary curve - x = sp.multiply(mag, sp.cos(phase)); - y = sp.multiply(mag, sp.sin(phase)); + x = np.real(z) + y = np.imag(z) if (Plot): # Plot the primary curve and mirror image ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ With this patch my nyquist plots look ok. What do you think of this change? Best regards Erik Fleischer -- Andrew Lewis: "Wenn Sie für einen Dienst nichts bezahlen, sind Sie offenbar nicht Kundin oder Kunde, sondern die Ware, die verkauft wird." |