我希望在Matlab中创建一个“报告生成”脚本。
假设我们有一个Matlab数组,data,并且我们想要将以下内容导出到.tex文件:
“data的第一个元素中的信息为X。”随后是X的绘图。
我已经尝试了在Matlab中使用help latex并了解了Matlab文件交换中的各种软件包。然而,到目前为止我还没有看到任何可以允许我导出文本和图形到同一个Matlab脚本并保存为.tex文件的方法。
如果您需要,publish函数也许适合您的需求。
创建这个脚本:foo.m
:
%%
% The information in the first element of data is X.
plot(X)
然后将其发布到LaTeX:
>> publish foo latex
你是否了解matlab2tikz?我在我的博士论文中广泛使用它,尽管只用于导出单个图形。但我想应该很容易地组合MATLAB的LaTeX导出功能。
从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');
% 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');