Skip to main content
19-Tanzanite
February 13, 2021
Solved

Discrepancy in Bode Plot: Phase - Frequency Plot -> Mathcad vs Matlab

  • February 13, 2021
  • 2 replies
  • 19097 views

Hello Dear Friends,

How can it be solved that the phase - frequency graph of the bode diagram in Mathcad looks like the phase - frequency graph of the bode diagram in Matlab?

CornelBejan_0-1613214031741.png

CornelBejan_1-1613214067968.png

CornelBejan_2-1613214089823.png

 

Calculations and graphs were made in Mathcad 15.
Attached is the Mathcad 15 file with the details.

Thank you.
Best regards.

 

Best answer by Werner_E

Matlab's bode somehow finds a way to examine the transfer function and so to determine the best range the phase should be placed at.

Mathcads arg function doesn't know anything about the transfer function - its simply receives a complex number and returns its argument, the angle, and this will always be in the range (-pi; +pi]. This range is as good as any other and its similar to the atan2 function. And thats also the reason you get the jump up to +180° step when the angle would go below -180°. "arg" would never give you an angle below (or equal to) -180°.

 

Easiest solution is to write an alternative "arg" function which returns the angle in a different 2 pi interval.

Werner_E_0-1613218601733.png

Put it at the top of the sheet (maybe in a collapsed region).

Or you may use an all-purpose "Arg" function where you can choose the start of the 2pi interval as its second argument:

Werner_E_1-1613218709691.png

The drawback of these simple solutions are, that you have to determine and chose the range for the angle manually yourself and that they only work OK as long as the range of angle values does not exceed a 2 pi interval.

 

2 replies

Werner_E25-Diamond IAnswer
25-Diamond I
February 13, 2021

Matlab's bode somehow finds a way to examine the transfer function and so to determine the best range the phase should be placed at.

Mathcads arg function doesn't know anything about the transfer function - its simply receives a complex number and returns its argument, the angle, and this will always be in the range (-pi; +pi]. This range is as good as any other and its similar to the atan2 function. And thats also the reason you get the jump up to +180° step when the angle would go below -180°. "arg" would never give you an angle below (or equal to) -180°.

 

Easiest solution is to write an alternative "arg" function which returns the angle in a different 2 pi interval.

Werner_E_0-1613218601733.png

Put it at the top of the sheet (maybe in a collapsed region).

Or you may use an all-purpose "Arg" function where you can choose the start of the 2pi interval as its second argument:

Werner_E_1-1613218709691.png

The drawback of these simple solutions are, that you have to determine and chose the range for the angle manually yourself and that they only work OK as long as the range of angle values does not exceed a 2 pi interval.

 

Cornel19-TanzaniteAuthor
19-Tanzanite
February 13, 2021

Ok.

Thank you very much for your response (for both comments/answers/suggestions).

Thank you.
Best regards.

25-Diamond I
February 13, 2021

I just noticed that most of what i said above was already covered in a thread of yours with a similar question

In this detailed discussion I provided a "bode" function which you could have used - why didn't you?

https://community.ptc.com/t5/PTC-Mathcad/Phase-Plot-Error-Bode-Diagrams/m-p/686828/highlight/true#M191806

 

Werner_E_0-1613219790007.png

Furthermore later in the very same discussion the "phasecor" function was brought to my/our attention and it could also help with the problem of discontinuities in bode plots:

Werner_E_1-1613220421977.png

 

 

 

 

ttokoro
21-Topaz I
21-Topaz I
February 13, 2021

image.pngimage.png

t.t.