2

I am a newcomer to LaTeX and came across PGF/TikZ by chance. Currently I try to draw the function graphs f(x) in PGF/TikZ, but with no success. Can anyone help me to read the data file from LTSpice with PGF/TikZ and draw them afterwards?


\documentclass{article}

\usepackage{pgfplots}
\usepackage{array}
\usepackage{booktabs}
\usepackage{pgfplotstable}

\begin{document}
\pgfplotstabletypesetfile{LM317.txt}
\end{document}

Error-Message: ! Text line contains an invalid character. t^^@ i^^@m^^@e^^@ ^^@V^^@(^^@n^^@0^^@0^^@5^^@)^^@ ^^@V^^@(^^@n^^@0^^... l.29 \pgfplotstabletypesetfile{LM317.txt} ^^M

enter image description here

Data as text (UTF-8)

time                   V(n005)       V(n001)        V(n003)
0.000000000000000e+00  0.000000e+00  0.000000e+00   0.000000e+00   
1.031821995489313e-99  1.994824e-06  1.102979e-18   9.197703e-25         
1.105501326095841e-09  2.155836e-06  5.366109e-19   -1.368576e-24        
1.252859987308896e-09  2.527454e-06  -7.874506e-18  -1.056591e-23        
1.547577309735008e-09  3.496970e-06  -2.185391e-17  -2.762964e-23        
2.137011954587231e-09  6.286433e-06  -3.816860e-17  -4.617686e-23        
3.022983821851659e-09  1.217947e-05  -3.697916e-17  -3.764493e-23        
3.877261642553005e-99  1.941849e-05  -5.500619e-18  2.255405e-23         
5.199523428066601e-09  3.129201e-05   2.971325e-17  1.256328e-22         
6.574180098003653e-09  4.121817e-05  -1.604368e-17  1.082905e-22         
8.179971204820860e-09  4.819972e-05  -4.373686e-17  2.275496e-23         
1.010285679622539e-08  5.403126e-05  2.425893e-17   -3.358998e-23         
1.189592599779081e-08  6.256012e-05  7.426873e-18   -2.161916e-22         
1.379091751168107e-08  7.659331e-05  -3.980423e-17  -5.083033e-22   
  • 2
    What is LTSpice? – AndréC Jan 12 at 6:52
  • 1
    Welcome to TeX.SX! Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Stefan Pinnow Jan 12 at 6:55
  • I don't know that LTSpice is, but you can use \draw plot[] (); to draw plots. For example, \draw plot[smooth,domain=-1:1] (\x,(\x)^2); gives you the plot of f(x)=x^2. – JouleV Jan 12 at 7:18
  • LTSpice is used for the simulation of electrical circuits. In this software it is possible to export the measuring points into a *.txt file. My approach would have been to call this file in LaTeX and draw the function graphs myself using PGF/TikZ. – user179354 Jan 12 at 8:30
  • \documentclass{article} \usepackage{pgfplots} \usepackage{array} \usepackage{booktabs} \usepackage{pgfplotstable} \begin{document} \pgfplotstabletypesetfile{LM317.txt} \end{document} Message: ! Text line contains an invalid character. <read 1> t^^@ i^^@m^^@e^^@ ^^@V^^@(^^@n^^@0^^@0^^@5^^@)^^@ ^^@V^^@(^^@n^^@0^^... l.29 \pgfplotstabletypesetfile{LM317.txt} – user179354 Jan 12 at 8:35
7

the ^^@ mean that your txt file is in UTF-16 which isn't the easiest format to handle. use your editor to resave the file in UTF-8

With the posted data, saved as UTF-16, you get

! Text line contains an invalid character.
<read 1> ��^^@
              t^^@i^^@m^^@e^^@ ^^@V^^@a^^@n^^@0^^@0^^@5^^@)^^@ ^^@V^^@(^^@n^...
l.9 \pgfplotstabletypesetfile{LM317.txt}
                                        ^^M
? 

the ^^@ are always an indication of UTF-16, as @ is character 32 so control-@, ^^@ is character 0 so the log is showing that you have a null byte between every character, which is exactly the encoding UTF-16 for characters in the ASCII range.

If You use an editor to resave the data as UTF-8 (or simply copy it back from this site) then your document runs without error, producing

enter image description here

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.