Matlab 中的文本和绘图到 LaTeX

发布于 2024-09-08 19:08:25 字数 270 浏览 4 评论 0原文

我喜欢在 Matlab 中创建“报告生成”脚本。

假设我们有一个 Matlab 数组 data 并且我们想要将以下内容导出到 .tex 文件: “数据第一个元素中的信息是X。”接下来是 X 的图。

我已经在 Matlab 中尝试过 help Latex 并了解 Matlab 文件交换上的各种包。然而,到目前为止,我还没有看到任何东西可以让我将同一个 Matlab 脚本中的文本和绘图导出到 .tex 文件。

I like to create a "report generation" script in Matlab.

Suppose we have a Matlab array, data and we want to export the following to a .tex file:
"The information in the first element of data is X." This would be followed by a plot of X.

I have already tried help latex in Matlab and aware of the various packages on Matlab file exchange. However I have seen nothing so far that will allow me to export both text and plots in the same Matlab script to a .tex file.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

恋竹姑娘 2024-09-15 19:08:25

您可能想看看发表在 TUGboat(TeX 用户组的官方杂志)上的这篇文章:

http://www.tug.org/TUGboat/Articles/tb24-2/tb77seta.pdf

通过 Matlab 生成 LaTeX 文档(SE Talole 和 SB Phadke)

祝你好运!

You might want to take a look at this article published in TUGboat (the official magazine of the TeX Users Group):

http://www.tug.org/TUGboat/Articles/tb24-2/tb77seta.pdf

Generating LaTeX documents through Matlab (S. E. Talole and S. B. Phadke)

Good luck!

向地狱狂奔 2024-09-15 19:08:25

发布功能可能适合您。

创建此脚本 foo.m

%%
% The information in the first element of data is X.

plot(X)

并将其发布到 LaTeX:

>> publish foo latex

The publish function may work for you.

Create this script, foo.m:

%%
% The information in the first element of data is X.

plot(X)

And publish it to LaTeX:

>> publish foo latex
揽月 2024-09-15 19:08:25

您知道 matlab2tikz 吗?我在我的博士论文中广泛使用了它,尽管仅用于导出单个图。但我想应该很容易就能组合出 MATLAB LaTeX 导出功能的强大功能。

Are you aware of matlab2tikz? i've used it extensively for my PhD-Thesis, albeit only for exporting single plots. But I guess it should be easily possible to whip something up that combines the power of MATLABs LaTeX export capabilities.

从﹋此江山别 2024-09-15 19:08:25

将图形从 Matlab 导出到 .tex 文件只需将图形导出为适当的格式,然后将图形文件包含在 .tex 文件中。下面列出的代码可以满足您的需求吗?

使用LaTeX生成dvi:

% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-depsc','-r100');
fprintf(fid,'\includegraphics[width=4in]{figure1.eps}\n');

使用pdfTeX生成pdf:

% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-djpg','-r100');
fprintf(fid,'\\includegraphics[width=4in]{figure1.jpg}\n');

Exporting figures from Matlab to a .tex file is just a matter of exporting the figure to an appropriate format and then including the figure file in the .tex file. Would something like the code listed below work for your needs?

Using LaTeX to generate dvi:

% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-depsc','-r100');
fprintf(fid,'\includegraphics[width=4in]{figure1.eps}\n');

Using pdfTeX to generate pdf:

% Include code to write text to .tex file (fid is assumed to be the file id of the .tex file)
print(gcf,'figure1','-djpg','-r100');
fprintf(fid,'\\includegraphics[width=4in]{figure1.jpg}\n');
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文