フィルターのクリア

Add title to images - MATLAB Report Generator

6 ビュー (過去 30 日間)
Lluis Roca
Lluis Roca 2021 年 2 月 9 日
回答済み: Aditi Charora 2021 年 7 月 8 日
How can I add title (e.g., Img1 and Img2) to the images below in the report?
Code:
import mlreportgen.dom.*
import mlreportgen.report.*
% To create a Word report, change the output type from "pdf" to "docx".
% To create an HTML report, change "pdf" to "html" or "html-file" for
% a multifile or single-file report, respectively.
rpt = Report('myreport', 'pdf');
imgStyle = {ScaleToFit(true)};
img1 = Image(which('ngc6543a.jpg'));
img1.Style = imgStyle;
img2 = Image(which('peppers.png'));
img2.Style = imgStyle;
lot = Table({img1, ' ', img2});
lot.entry(1,1).Style = {Width('3.2in'), Height('3in')};
lot.entry(1,2).Style = {Width('.2in'), Height('3in')};
lot.entry(1,3).Style = {Width('3.2in'), Height('3in')};
lot.Style = {ResizeToFitContents(false), Width('100%')};
add(rpt, lot);
close(rpt);
rptview(rpt);

回答 (1 件)

Aditi Charora
Aditi Charora 2021 年 7 月 8 日
Hi Lluis,
Below is an example code that adds title to the images:
import mlreportgen.dom.*
import mlreportgen.report.*
% To create a Word report, change the output type from "pdf" to "docx".
% To create an HTML report, change "pdf" to "html" or "html-file" for
% a multifile or single-file report, respectively.
rpt = Report('myreport', 'pdf');
imgStyle = {ScaleToFit(true)};
img1 = Image(which('ngc6543a.jpg'));
img1.Style = imgStyle;
img2 = Image(which('peppers.png'));
img2.Style = imgStyle;
lot = Table({'Boeing 747', ' ', 'Peppers';img1, ' ', img2});
lot.entry(2,1).Style = {Width('3.2in'), Height('3in')};
lot.entry(2,2).Style = {Width('.2in'), Height('3in')};
lot.entry(2,3).Style = {Width('3.2in'), Height('3in')};
lot.row(1).Style = {HAlign('center')};
lot.Style = {ResizeToFitContents(false), Width('100%')};
add(rpt, lot);
close(rpt);
rptview(rpt);
Thanks,
Aditi

カテゴリ

Help Center および File ExchangeMATLAB Report Generator Task Examples についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by