[Tex/LaTex] Undefined control sequence \text when importing Matlab figures

external filesMATLABpgfplotstikz-pgf

I'm following a tutorial to import Matlab figures through tikz, however after trying to compile the .tex file I get the following error:

ABD: EveryShipout initializing macros (./mysphere.tikz
! Undefined control sequence.
<recently read> \text 

l.1005 \end{axis}

? 

I created the mysphere.tikz file exactly as described in the link, and I am including the file in LaTeX as indicated:

\begin{figure} 
    \centering 
    \newlength\figureheight
    \newlength\figurewidth
    \setlength\figureheight{6cm}
    \setlength\figurewidth{6cm}
    \input{mysphere.tikz}
    \caption{A plot of a sphere}
    \label{fig:sphere}
\end{figure} 

I am using TeXworks and pdflatex to compile the file, on Ubuntu 12.10.

Best Answer

So I found the error. Apparently the matlab2tikz script "overcomplicates" the title conversion from matlab, with a sphere: x^2+y^2+z^2 from Matlab ending up as $\text{a sphere: x}^\text{2}\text{+y}^\text{2}\text{+z}^\text{2}$, while a sphere: $x^2+y^2+z^2$ is a more correct translation (no errors whatsoever with this title).