Report Generator で作成したpdfファイルを特定のパスで指定したフォルダに保存する方法
Show older comments
Matlabの「Report Generator」で作成したpdfファイルをMatlabで現在開いているフォルダでなく、
指定したパスのフォルダ内に保存したいです。
「Report Generator」を使ったことがなく、初心者で以下の公式ページを参考にしながらpdfファイルを作っています。
(公式ページ:https://jp.mathworks.com/help/rptgen/ug/create-a-landscape-report.html)
以下の公式のコード例では、変数「Path」で宣言した「test」という名のフォルダに作成したpdfファイルを保存したい場合
どの関数に変数「Path」を組み込めばいいでしょうか。特に指定しない場合は、現在のフォルダーに保存されます。
お手数をおかけしますが、教えていただけますと、幸いです。
%pdfファイルを保存したパス
Path = "testファイル/test"
% 公式ページのコード例(https://jp.mathworks.com/help/rptgen/ug/create-a-landscape-report.html)
import mlreportgen.dom.*;
import mlreportgen.report.*;
rpt = Report("figureSnapshotSideBySideLandscape","pdf");
rpt.Layout.Landscape = true;
chapter = Chapter("Title", "Types of Cosine Value Plots with Random Noise");
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
imgStyle = {ScaleToFit(true)};
fig1 = Figure(bar(x, y));
fig1Img = Image(getSnapshotImage(fig1, rpt));
fig1Img.Style = imgStyle;
delete(gcf);
fig2 = Figure(scatter(x,y));
fig2Img = Image(getSnapshotImage(fig2, rpt));
fig2Img.Style = imgStyle;
delete(gcf);
fig3 = Figure(plot(x,y));
fig3Img = Image(getSnapshotImage(fig3, rpt));
fig3Img.Style = imgStyle;
delete(gcf);
lo_table = Table({fig1Img, ' ', fig2Img, ' ',fig3Img});
lo_table.entry(1,1).Style = {Width('3.2in'), Height('3in')};
lo_table.entry(1,2).Style = {Width('.2in'), Height('3in')};
lo_table.entry(1,3).Style = {Width('3.2in'), Height('3in')};
lo_table.entry(1,4).Style = {Width('.2in'), Height('3in')};
lo_table.entry(1,5).Style = {Width('3in'), Height('3in')};
add(chapter, lo_table);
add(rpt, chapter);
chapter1 = Chapter("Title", "Surface Plot");
fig4 = Figure(surf(peaks(20)));
fig4Img = Image(getSnapshotImage(fig4, rpt));
fig4Img.Style = imgStyle;
delete(gcf);
add(chapter1, fig4Img);
add(rpt, chapter1);
close(rpt);
rptview(rpt);
Accepted Answer
More Answers (0)
Categories
Find more on MATLAB Report Generator のタスクの例 in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!