4
\$\begingroup\$

After I plotted the frequency response of a circuit using LTSpice as shown:

enter image description here

I exported the plots data as a .txt file in order to plot them after that using MATLAB, however, after I plotted the data using MATLAB I discovered that the exported data from LTSpice has the phase wrapped, as shown:

enter image description here

Is there a way to export the LTSpice frequency response without having the phase wrapped?

\$\endgroup\$
  • \$\begingroup\$ This is probably a choice made due to a requirement that \$\frac{-\pi}{2}\le\operatorname{atan}\left(\frac{Im}{Re}\right)\le\frac{\pi}{2}\$ when only the positive value from the \$\sqrt{Re^2+Im^2}\$ is always selected. \$\endgroup\$ – jonk Apr 18 '19 at 22:29
1
\$\begingroup\$

I think you cannot fix this in LTSpice.
I didn't find hard evidence, but very plausible evidence.
If you hover over the angle axis (you'll see a ruler) and left click it, there is an option to Unravel Branch Wrap. Why would the option here if there were no reason to unravel it?

enter image description here

If you deselect it, you'll see the same output as MATLAB shows.

So, I think you should unravel the data yourself, in MATLAB.

| improve this answer | |
\$\endgroup\$
  • \$\begingroup\$ I'm no expert on MATLAB, therefore this in a comment: You could use something like wrapTo360(lon)-360 or using modulo, or if (angle>0) subtract 360° \$\endgroup\$ – Huisman Apr 18 '19 at 21:29
  • \$\begingroup\$ The unwrapping option is there to be applied to the already calculated data. Whether you check, or uncheck the option, the data doesn't change (the .raw file stays the same), which means that after exporting to Matlab, the option to wrap/unwrap is left to the user, the same way the option exists in LTspice. So the conclusion is correct: unwrapping must be done in Matlab. \$\endgroup\$ – a concerned citizen Apr 19 '19 at 6:53
0
\$\begingroup\$

You can post process .raw files using Python and ltspice_pytool. PyPi GitHub

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.