pstool, psfragfig and matlabfrag ambiguity

I am trying to use matlabfrag package in order to use pdflatex along with pstool. There is some kind of a strange issue which I could not understand. I exported some figures from MATLAB with the matlabfrag script.

And I downloaded the matlabfrag script on gitbub which seems to include some fixes, I also ended up with this script through this thread: Matlabfrag figure in latex

Here is my MWE

% MWE
\documentclass{article}
\usepackage{amsmath}
\usepackage[osf,sc]{mathpazo}
\usepackage[mode=errorstop,crop=pdfcrop,process=all]{pstool}
\usepackage{tikz}
\usetikzlibrary{calc}
\begin{document}

% figure 1
\begin{figure}
\centering
\psfragfig[width=\textwidth]{test_matlabfrag}
\end{figure}

% figure 2
\begin{figure}
\centering
\psfragfig[width=\textwidth]{sine}
\end{figure}

\end{document}


There are no problems with figure 2 but I am experiencing a similar problem as explained in the above thread with a red error box. And if I look inside the log file as explained there, I can see:

! Missing $inserted. <inserted text>$
l.23 ...hics [width=\textwidth ] {test_matlabfrag}


Update/Edit: This might be maybe useful for some other people in the future.

The general problem was in the tex file there was an error as mentioned in the accepted answer from David. I deleted the original files.

Any pointers on the source of error for the first file/figure inclusion is appreciated.

The TeX file has

\psfrag{008}[rc][rc]{\matlabtextB 10^{-4}}%
\psfrag{009}[rc][rc]{\matlabtextB 10^{-3}}%
\psfrag{010}[rc][rc]{\matlabtextB 10^{-2}}%
\psfrag{011}[rc][rc]{\matlabtextB 10^{-1}}%
\psfrag{012}[rc][rc]{\matlabtextB 10^{0}}%
\psfrag{013}[rc][rc]{\matlabtextB 10^{1}}%
%


which is inserting a TeX syntax error as it should be in math mode

\psfrag{008}[rc][rc]{\matlabtextB $10^{-4}$}%
\psfrag{009}[rc][rc]{\matlabtextB $10^{-3}$}%
\psfrag{010}[rc][rc]{\matlabtextB $10^{-2}$}%
\psfrag{011}[rc][rc]{\matlabtextB $10^{-1}$}%
\psfrag{012}[rc][rc]{\matlabtextB $10^{0}$}%
\psfrag{013}[rc][rc]{\matlabtextB $10^{1}$}%

• Indeed thanks, I was so blind to see this ;-) – Umut Tabak Mar 2 '17 at 22:39