I have a folder containing *.png images generated using a different program. I would like to insert these into a word document.
What I have done so far:
Following the "Getting Started" tutorial I imported two classes (or methods?):
import mlreportgen.report.*import mlreportgen.dom.*
I created a report object:
rpt = Report('C:\reportpath\report','docx');
I created a section with a section title:
sec(1) = Section;sec(1).Title = ['Test conducted using parameter 1: ' num2str(par(1)) ', and parameter 2: ' par(2)'];
And then I try to insert an image, and this is where I don't understand the documentation. My first attempt was:
fig1 = Image;Error using mlreportgen.dom.ImageNo constructor 'mlreportgen.dom.Image' with matching signature found.
My second attempt was:
fig1 = rptgen.cfr_image;fig1.Image = srcfig1{7};Unrecognized property 'Image' for class 'rptgen.cfr_image'.
My latest attempt was:
fig1 = rptgen.cfr_image;fig1.FileName = 'figure1.png';
As this did not give me an error message I added it to the section / document:
add(sec(1),fig1); % insert figure into section
add(rpt,sec(1));close(rpt);
What appears in the word document is just the text:
[1×1 rptgen.cfr_image]
Previously I tried using "imread" to read the image into the matlab workspace and then "imagesc" to plot it on a figure, but the quality was very poor. Hence I would like to insert the *.png file directly.
Best Answer