# Is this a MATLAB bode phase plot error? I sent in a function $$T = -0.1 \frac{s+400}{(s+20)*(s+2000)}$$

> T = -0.1*(s+400)/((s+20)*(s+2000));
> bode(T)
> grid on


I was expecting the phase to start at -180 deg, but instead the MATLAB is showing +180 deg.

Is this an inconsistency or a conceptual thing?

• Why do you expect it to start at -180? – justing Apr 12 '15 at 4:03

You can add or subtract 360 deg (pi rad) as many times as needed in Bode phase graph. Right click in your graph, Properties > Options > Phase Response > Adjust phase offsets [on] > Keep phase close to [-pi] (in your case), At frequency [0.000]. Done in MATLAB R2015a.

• you mean 2pi rad – Scott Seidman Jan 14 '16 at 14:26

The phase plot should start at -180. You need to write the numerator block as (-0.1s -40)

• Chu so what might be causing matlab to plot it at +180 deg? – Carlos - the Mongoose - Danger Apr 12 '15 at 16:18
• I suspect that it's interpretted the -0.1, on the negative real axis, as +180 instead of -180, then, at say 1 rad/s, the overall phase angle would be 180 + atan(1/400) - atan(1/20) - atan(1/2000)= 180+0.14-2.86-0.03 = 177.25. And so on at other frequencies. – Chu Apr 12 '15 at 18:15
• ... consider w=20 rad/s, where the Matlab phase is just greater than +135 from your graph. Using +180 for the -0.1 term instead of -180 will give: 180+atan(20/400)-atan(20/20)-atan(20/2000) = 180+2.86-45-0.57 = 138. True phase angle is -222 – Chu Apr 12 '15 at 18:27
• +180 degrees and -180 degrees are the same angle. Your answer is not correct – Scott Seidman Jan 14 '16 at 14:25
• @Scott Seidman, At $\omega=0$ the vector is along the -ve real axis. As $\omega$ increases, the first term to have an effect is the $(s+20)$ lag which adds phase lag and hence rotates the vector clockwise into the 2nd quadrant. This represents a total phase lag which is greater than 180deg – Chu Jan 14 '16 at 17:22

When you doubt your tools goto 1st principals or use other tools

http://www.wolframalpha.com/input/?i=Bode+plot+of+-0.1*%28s%2B400%29%2F%28%28s%2B20%29*%28s%2B2000%29%29+sampling+period+.02 at $\omega=0$

$T = -0.1 \frac{s+400}{(s+20)*(s+2000)}$ reduces to -0.001

With negative gain the phaseshift is +180degrees (or -180 ;) )

• To check a Matlab answer, Excel is probably better than a package that uses a more 'sophisticated' algorithm like Wolfram, where you don't really know what it's doing. In Excel you can use ATAN2 which resolves the phase angle issue. If you're plotting on a logarithmic frequency scale, w=0 or 'DC' does not exist, so the low frequency phase angle rounds to -180, not to +180 – Chu Apr 12 '15 at 9:59
• I don't disagree, Excel is great. I guess it comes downto exactly what he is trying todo – JonRB Apr 12 '15 at 10:06
• The true phase angle is always lagging, it is never positive. eg, at 100rad/s, the true phase angle is (-166-79-3)=-248. Wolfram is giving something quite different. – Chu Apr 12 '15 at 10:23
• @Chu, you can do EXACTLY the same thing in Matlab. Just because there are high level functions available, it doesn't mean that you have to use them. – Scott Seidman Jan 14 '16 at 21:31
• It's all about readability. It's like using different scales on the axes of a root locus - strictly correct, but does not lend itself to design. – Chu Jan 15 '16 at 0:48

Just FYI for your normal phase plot. You can add some options to the bode plot:

opts = bodeoptions('cstprefs');

opts.PhaseWrapping = 'on';

opts.PhaseWrappingBranch = -180;

bode(***your_transfer_function***, opts);