将matlab作的图导入到latex的方法 matlab2tikz

现在几乎绝大多数的论文都会有仿真,并且需要作图来直观表现算法性能。本文介绍一种将matlab作的图导入到latex的方法。

  1. 打开如下网址:matlab2tikz 的github 地址

  2. 网址界面如下,点击下图一中的clone and download 或者 图二中的 update manually 对matlab2tikz 进行下载。
    图1
    图2

  3. 解压zip 文件,并在matlab 中选择 set path,将src\添加至路径
    这里写图片描述
    这里写图片描述

  4. 运行matlab 程序,生成图片,在commond window 输入命令matlab2tikz('plot1.tikz') 如下图所示这里写图片描述

  5. 在matlab 所运行程序的当前目录下,生成如下文件:
    这里写图片描述

  6. latex 文件所在目录下建一个名为tikz 的文件夹,将生成的tikz文件复制到tikz 文件夹下,并在latex中需添加如下代码:

\documentclass{article}\usepackage{pgfplots}\pgfplotsset{compat=newest}%% the following commands are needed for some matlab2tikz features\usetikzlibrary{plotmarks}\usetikzlibrary{arrows.meta}\usepgfplotslibrary{patchplots}\usepackage{grffile}\usepackage{amsmath}\newcommand{\tikzdir}[1]{tikz/#1.tikz}%% you may also want the following commands%\pgfplotsset{plot coordinates/math parser=false}%\newlength\figureheight%\newlength\figurewidth\begin{document}\begin{figure}[h!]\centering\inputtikz{plot1}\end{figure}
\end{document}
  1. 生成图片如下,放大不会改变清晰度,比截图要更严谨更准确。

这里写图片描述


本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!

相关文章

立即
投稿

微信公众账号

微信扫一扫加关注

返回
顶部