Matlab2tikz // 误差除以 0.0

Matlab2tikz // 误差除以 0.0

我在 Matlab 中创建了一个最小的工作示例:

[x,y] = meshgrid(-2:0.1:2,-2:0.1:2);
fx = x.*y;
fy = x.*y;

figure
quiver(x,y,fx,fy)

matlab2tikz('plot.tex');

这很有效并创建了 plot.tex 文档。

所以现在我将文件包含在我的文件中

\documentclass{article} 
\usepackage{pgfplots} 
\pgfplotsset{compat=newest} 
\pgfplotsset{plot coordinates/math parser=false} 
\newlength\figureheight 
\newlength\figurewidth 
\usetikzlibrary{arrows.meta}
\begin{document} 
\input{plot.tex} 
\end{document}

编译时出现以下错误:

(plot.tex
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <7> on input line 1710.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <5> on input line 1710.


! Package PGF Math Error: You've asked me to divide `0.0' by `0.0', but I canno
t divide any number by `0.0'.

See the PGF Math package documentation for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.1710 \end{axis}

This error message was generated by an \errmessage
command, so I can't give any explicit help.
Pretend that you're Hercule Poirot: Examine all clues,
and deduce the truth by order and method.

! Arithmetic overflow.
\pgfmathdivide@ ...\pgfmath@x by\c@pgfmath@counta 
                                                  \else \ifdim 0pt>\pgfmath@...
l.1710 \end{axis}

I can't carry out that multiplication or division,
since the result is out of range.

! Undefined control sequence.
\pgfplotsaxisvisphasetransformpointmeta ...@trafo 
                                                  {\pgfplotspointmeta }\let ...
l.1710 \end{axis}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

! Undefined control sequence.
\pgfplotsaxisvisphasetransformpointmeta ...ntmeta 
                                                  }\let \pgfplotspointmetatr...
l.1710 \end{axis}

The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

)

我不知道为什么会发生这种情况。

plot.tex 文件的链接是https://pastebin.com/J5kvy0rm

我非常感谢你的帮助:)


编辑

简化的 MWE 可重现错误:

\documentclass{article} 
\usepackage{pgfplots} 
\pgfplotsset{compat=newest} 
\pgfplotsset{plot coordinates/math parser=false} 
\newlength\figureheight 
\newlength\figurewidth 
\usetikzlibrary{arrows.meta}
\definecolor{mycolor1}{rgb}{0.00000,0.44700,0.74100}%
\begin{document} 
\begin{tikzpicture}
\begin{axis}[%
width=6.028in,
height=4.754in,
at={(1.011in,0.642in)},
scale only axis,
xmin=-2.5,
xmax=2.5,
ymin=-2.5,
ymax=2.5,
axis background/.style={fill=white},
legend style={legend cell align=left, align=left, draw=white!15!black}
]
\addplot[-Straight Barb, color=mycolor1, point meta={sqrt((\thisrow{u})^2+(\thisrow{v})^2)}, point meta min=0, quiver={u=\thisrow{u}, v=\thisrow{v}, every arrow/.append style={-{Straight Barb[angle'=18.263, scale={10/1000*\pgfplotspointmetatransformed}]}}}]
 table[row sep=crcr] {%
x   y   u   v\\
-2  -2  0.0878048780487805  0.0878048780487805\\
-2  -1.9    0.0834146341463415  0.0834146341463415\\
-2  -1.8    0.0790243902439025  0.0790243902439025\\
-2  -1.7    0.0746341463414634  0.0746341463414634\\
-2  -1.6    0.0702439024390244  0.0702439024390244\\
-2  -1.5    0.0658536585365854  0.0658536585365854\\
-2  -1.4    0.0614634146341464  0.0614634146341464\\
};
\addlegendentry{data1}

\end{axis}
\end{tikzpicture}%
\end{document} 

编辑 在此处输入图片描述

相关内容