Hey guys,
I'm using Generate Report to creat a pdf-File. By using a surface plot it is possible to add the image to the pdf-file. I also want to add another rgb-image to this pdf-file, but I get the following error message:
Error using mlreportgen.report.Figure/createSnapshotFigure
Figure is invalid. Please use valid path of the figure file or valid figure handle
….
Error in test (line 58)
add(report,c1);
I use the following code:
%Import the DOM and Report API packages so you do not have to use long class names.
import mlreportgen.dom.*import mlreportgen.report.*%Create a container to hold the report content.
doctype = 'pdf'; %Also working with 'docx'
report = Report("Auswertung", doctype);open(report);%% Create title page
tp = TitlePage("Title", "Ergebnisse test", "Subtitle", "test");add(report, tp);%% Table of Contents
toc = TableOfContents;add(report, toc);%% Create a chapter with the title
c1 = Chapter("Title", "Ergebnisse");c2 = Chapter("Title", "Nächstes Kapitel: ");%% Data
s1 = Section("Messdaten");p1 = Text("Aufnahme in [cd/m²]");s2 = Section("Maske");[name_gray, path_gray] = uigetfile('*.*', 'Select gray value image');[name_rgb, path_rgb] = uigetfile('*.*', 'Select rgbe image');picture_data = dlmread(fullfile(path_gray, name_gray)); %Example Path
groups_rgb = imread(fullfile(path_rgb, name_rgb)); %Example Path%% Gray value image
figure();ax = gca;Fig1 = Figure(surf(ax, picture_data));%Plot the measurement data as surf plot
axis equalshading interpcolorbarview(0,-90) add(s1, p1);add(s1,Fig1);close(gcf);%% RGB image
figure();imshow(groups_rgb);Fig2 = Figure();add(s2,Fig2);%% Create Report
add(c1, s1);add(c1, s2);add(report,c1);add(report,c2);close(report);rptview(report);
I use a MacBook Pro (Mac OSX), Matlab Version R2019a. I tryed it in some different versions but its just not working. Maybe someone of you can help me. Thank you very much!
Best, Raphael
Best Answer